{"id":111762,"date":"2025-09-04T15:56:11","date_gmt":"2025-09-04T10:26:11","guid":{"rendered":"https:\/\/www.mygreatlearning.com\/blog\/?page_id=111762"},"modified":"2025-09-04T15:34:35","modified_gmt":"2025-09-04T10:04:35","slug":"c-exercise","status":"publish","type":"page","link":"https:\/\/www.mygreatlearning.com\/blog\/c-exercise\/","title":{"rendered":"C Exercises"},"content":{"rendered":"\n\n    <style>\n        \/* General styles *\/\n        .c-input {\n\n            border-bottom: 1px dashed #9CA3AF !important;\n\n        }\n        .c-input:focus {\n            outline: none;\n            background-color: #E0E7FF;\n            border-bottom: 1px solid #3B82F6;\n        }\n\n        .c-select {\n            font-family: monospace;\n            background-color: #F3F4F6;\n            border: 1px dashed #9CA3AF;\n            font-size: 0.875rem; \/* 14px *\/\n            color: #1D4ED8;\n            border-radius: 4px;\n            padding: 1px;\n        }\n        .c-select:focus {\n            outline: none;\n            border: 1px solid #3B82F6;\n        }\n        \n        .c-code-template {\n            background-color: #F9FAFB;\n            padding: 1rem;\n            border-radius: 0.375rem;\n            font-size: 0.95rem;\n            color: #374151;\n            line-height: 1.6;\n        }\n\n        \/* CSS class for topic buttons for cleaner HTML and hover effects *\/\n        .topic-item-btn {\n            background-color: #FFFFFF;\n            padding: 1.5rem;\n            border-radius: 0.5rem;\n            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);\n            text-align: left;\n            width: 100%;\n            border: 1px solid #E5E7EB;\n            cursor: pointer;\n            transition: all 0.2s ease;\n        }\n        .topic-item-btn:hover {\n            transform: translateY(-3px)\n            box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);\n              background-color: white;\n        }\n    <\/style>\n\n<div class=\"c-ex-container\" style=\"font-family: sans-serif; background-color: #FFFFFF; color: #1F2937; max-width: 56rem; width: 100%; margin: 2rem auto; border-radius: 1rem; box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04); padding: 1.5rem;\">\n\n    <div id=\"c-ex-topic-selection-view\">\n        <h1 style=\"font-size: 1.875rem; line-height: 2.25rem; font-weight: 700; text-align: center; color: #111827; margin-bottom: 0.5rem;\" style=\"font-size: 1.875rem; line-height: 2.25rem; font-weight: 700; text-align: center; color: #111827; margin-bottom: 0.5rem;\" id=\"c-practice-exercises\">C Practice Exercises<\/h1>\n        <p style=\"text-align: center; color: #6B7280;\"> Sharpen your C programming skills with coding practice, exercises, and problems online. Ideal for beginners learning C language and preparing for exams.<\/p>\n        <p style=\"text-align: center; color: #6B7280; margin-bottom: 2rem;\">Select a topic to start the exercise.<\/p>\n\n        <div id=\"c-ex-topic-grid\" style=\"display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1.5rem;\">\n            <button class=\"topic-item-btn\" data-topic-key=\"CBasics\">\n                <h3 style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" id=\"c-basics\">C Basics<\/h3>\n                <p style=\"color: #6B7280; margin: 0;\">5 exercise questions<\/p>\n            <\/button>\n            <button class=\"topic-item-btn\" data-topic-key=\"VariablesDataTypes\">\n                <h3 style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" id=\"variables-data-types\">Variables & Data Types<\/h3>\n                <p style=\"color: #6B7280; margin: 0;\">5 exercise questions<\/p>\n            <\/button>\n            <button class=\"topic-item-btn\" data-topic-key=\"Arrays\">\n                <h3 style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" id=\"arrays\">Arrays<\/h3>\n                <p style=\"color: #6B7280; margin: 0;\">5 exercise questions<\/p>\n            <\/button>\n            <button class=\"topic-item-btn\" data-topic-key=\"Strings\">\n                <h3 style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" id=\"strings\">Strings<\/h3>\n                <p style=\"color: #6B7280; margin: 0;\">5 exercise questions<\/p>\n            <\/button>\n            <button class=\"topic-item-btn\" data-topic-key=\"ControlFlow\">\n                <h3 style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" id=\"control-flow\">Control Flow<\/h3>\n                <p style=\"color: #6B7280; margin: 0;\">5 exercise questions<\/p>\n            <\/button>\n            <button class=\"topic-item-btn\" data-topic-key=\"Functions\">\n                <h3 style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" id=\"functions\">Functions<\/h3>\n                <p style=\"color: #6B7280; margin: 0;\">5 exercise questions<\/p>\n            <\/button>\n            <button class=\"topic-item-btn\" data-topic-key=\"Pointers\">\n                <h3 style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" id=\"pointers\">Pointers<\/h3>\n                <p style=\"color: #6B7280; margin: 0;\">5 exercise questions<\/p>\n            <\/button>\n            <button class=\"topic-item-btn\" data-topic-key=\"Structures\">\n                <h3 style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" id=\"structures\">Structures<\/h3>\n                <p style=\"color: #6B7280; margin: 0;\">5 exercise questions<\/p>\n            <\/button>\n            <button class=\"topic-item-btn\" data-topic-key=\"Loops\">\n                <h3 style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" id=\"loops\">Loops<\/h3>\n                <p style=\"color: #6B7280; margin: 0;\">5 exercise questions<\/p>\n            <\/button>\n            <button class=\"topic-item-btn\" data-topic-key=\"MemoryManagement\">\n                <h3 style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" id=\"memory-management\">Memory Management<\/h3>\n                <p style=\"color: #6B7280; margin: 0;\">5 exercise questions<\/p>\n            <\/button>\n            <button class=\"topic-item-btn\" data-topic-key=\"FileIO\">\n                <h3 style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" id=\"file-i-o\">File I\/O<\/h3>\n                <p style=\"color: #6B7280; margin: 0;\">5 exercise questions<\/p>\n            <\/button>\n            <button class=\"topic-item-btn\" data-topic-key=\"PreprocessorDirectives\">\n                <h3 style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" style=\"font-size: 1.25rem; font-weight: 700; color: #1F2937; margin: 0 0 0.25rem 0;\" id=\"preprocessor-directives\">Preprocessor Directives<\/h3>\n                <p style=\"color: #6B7280; margin: 0;\">5 exercise questions<\/p>\n            <\/button>\n            <noscript>\n                <p style=\"text-align: center; background-color: #FEF2F2; color: #991B1B; padding: 1rem; border-radius: 0.5rem; grid-column: 1 \/ -1;\">\n                    The interactive exercises on this page require JavaScript. Please enable it in your browser to start practicing.\n                <\/p>\n            <\/noscript>\n        <\/div>\n    <\/div>\n\n    <div id=\"c-ex-exercise-views-container\">\n        <\/div>\n\n<\/div>\n\n<script>\nconst exercises = {\n    \"C Basics\": [\n        { question: \"Print 'Hello, C!' to the console, followed by a newline.\", template: [ { type: \"input\", size: 7, placeholder: \"function\" }, \"(\\\"Hello, C!\\\\n\\\");\" ], solution: [\"printf\"] },\n        { question: \"Declare an integer variable named `age` and initialize it to 25.\", template: [ { type: \"input\", size: 4, placeholder: \"type\" }, \" age = 25;\" ], solution: [\"int\"] },\n        { question: \"Which header file is required for `printf`?\", template: [ \"#include <\", { type: \"input\", size: 8, placeholder: \"header\" }, \">\" ], solution: [\"stdio.h\"] },\n        { question: \"Write a single-line comment.\", template: [ { type: \"input\", size: 2, placeholder: \"\/\/\" }, \" This is a comment\" ], solution: [\"\/\/\"] },\n        { question: \"What is the integer result of the division `10 \/ 3` in C?\", template: [ \"\/\/ 10 \/ 3 results in \", { type: \"input\", size: 2, placeholder: \"num\" } ], solution: [\"3\"] }\n    ],\n    \"Variables & Data Types\": [\n        { question: \"Declare a float variable `price` and initialize it to 19.99.\", template: [ { type: \"input\", size: 6, placeholder: \"type\" }, \" price = 19.99f;\" ], solution: [\"float\"] },\n        { question: \"What is the `printf` format specifier for a double?\", template: [ \"printf(\\\"\", { type: \"input\", size: 4, placeholder: \"specifier\" }, \"\\\", 3.14);\" ], solution: [\"%lf\"] },\n        { question: \"Declare a character variable `grade` and set it to 'A'.\", template: [ { type: \"select\", options: [\"char\", \"string\", \"int\"] }, \" grade = 'A';\" ], solution: [\"char\"] },\n        { question: \"Declare a constant integer `MAX` with a value of 100.\", template: [ { type: \"input\", size: 6, placeholder: \"keyword\" }, \" int MAX = 100;\" ], solution: [\"const\"] },\n        { question: \"What data type would you use for a simple true\/false flag?\", template: [ \"_Bool is_active = \", { type: \"select\", options: [\"true\", \"1\", \"YES\"] }, \";\" ], solution: [\"1\"] }\n    ],\n    \"Arrays\": [\n        { question: \"Declare an array `numbers` of 5 integers.\", template: [ \"int numbers[\", { type: \"input\", size: 2, placeholder: \"size\" }, \"];\" ], solution: [\"5\"] },\n        { question: \"Access the third element of an array `arr`.\", template: [ \"value = arr[\", { type: \"input\", size: 2, placeholder: \"index\" }, \"];\" ], solution: [\"2\"] },\n        { question: \"What is the index of the first element in a C array?\", template: [ \"The first index is \", { type: \"input\", size: 2, placeholder: \"num\" }, \".\" ], solution: [\"0\"] },\n        { question: \"Declare and initialize a character array `name` to 'John'.\", template: [ \"char name[] = \", { type: \"input\", size: 8, placeholder: \"\\\"value\\\"\" }, \";\" ], solution: [\"\\\"John\\\"\"] },\n        { question: \"Calculate the number of elements in an integer array `arr`.\", template: [ \"int len = sizeof(arr) \", { type: \"input\", size: 2, placeholder: \"op\" }, \" sizeof(arr[0]);\" ], solution: [\"\/\"] }\n    ],\n    \"Strings\": [\n        { question: \"In C, a string is an array of characters ending with what special character?\", template: [ \"The null terminator: '\", { type: \"input\", size: 4, placeholder: \"char\" }, \"'\" ], solution: [\"\\\\0\"] },\n        { question: \"Which function is used to find the length of a string?\", template: [ \"int len = \", { type: \"input\", size: 7, placeholder: \"function\" }, \"(my_string);\" ], solution: [\"strlen\"] },\n        { question: \"Concatenate string `s2` onto the end of string `s1`.\", template: [ { type: \"input\", size: 7, placeholder: \"function\" }, \"(s1, s2);\" ], solution: [\"strcat\"] },\n        { question: \"Which header file is needed for string functions like `strlen`?\", template: [ \"#include <\", { type: \"input\", size: 9, placeholder: \"header\" }, \">\" ], solution: [\"string.h\"] },\n        { question: \"Compare two strings `s1` and `s2` for equality.\", template: [ \"if (\", { type: \"input\", size: 7, placeholder: \"function\" }, \"(s1, s2) == 0)\" ], solution: [\"strcmp\"] }\n    ],\n    \"Control Flow\": [\n        { question: \"Write an if statement to check if `x` is greater than 0.\", template: [ { type: \"select\", options: [\"if\", \"for\", \"while\"] }, \" (x > 0) { ... }\" ], solution: [\"if\"] },\n        { question: \"Write the structure of a `for` loop that counts from 0 to 9.\", template: [ \"for (int i = 0; i < 10; \", { type: \"input\", size: 4, placeholder: \"i++\" }, \") { ... }\" ], solution: [\"i++\"] },\n        { question: \"Complete the `switch` statement to handle the case where `num` is 1.\", template: [ \"switch (num) {<br>&nbsp;&nbsp;&nbsp;&nbsp;\", { type: \"input\", size: 6, placeholder: \"case\" }, \" 1:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(\\\"One\\\");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br>}\" ], solution: [\"case\"] },\n        { question: \"What keyword immediately exits the current loop?\", template: [ { type: \"select\", options: [\"break\", \"continue\", \"exit\"] } ], solution: [\"break\"] },\n        { question: \"Complete this `if-else` statement.\", template: [ \"if (condition) {<br>&nbsp;&nbsp;&nbsp;&nbsp;...<br>} \", { type: \"input\", size: 5, placeholder: \"else\" }, \" {<br>&nbsp;&nbsp;&nbsp;&nbsp;...<br>}\" ], solution: [\"else\"] }\n    ],\n    \"Functions\": [\n        { question: \"Define a function `greet` that takes no arguments and returns nothing.\", template: [ { type: \"input\", size: 5, placeholder: \"type\" }, \" greet() { ... }\" ], solution: [\"void\"] },\n        { question: \"Define a function `add` that returns the sum of two integers.\", template: [ \"int add(int a, int b) {<br>&nbsp;&nbsp;&nbsp;&nbsp;\", { type: \"input\", size: 7, placeholder: \"keyword\" }, \" a + b;<br>}\" ], solution: [\"return\"] },\n        { question: \"Call the `add` function with arguments 5 and 3.\", template: [ \"int sum = \", { type: \"input\", size: 9, placeholder: \"call\" }, \";\" ], solution: [\"add(5, 3)\"] },\n        { question: \"A function declaration, also known as a function...\", template: [ \"...is called a function \", { type: \"input\", size: 9, placeholder: \"prototype\" }, \".\" ], solution: [\"prototype\"] },\n        { question: \"What is the return type of the main entry point of a C program?\", template: [ { type: \"input\", size: 4, placeholder: \"type\" }, \" main() { ... }\" ], solution: [\"int\"] }\n    ],\n    \"Pointers\": [\n        { question: \"Declare a pointer `ptr` that can point to an integer.\", template: [ \"int \", { type: \"input\", size: 2, placeholder: \"char\" }, \"ptr;\" ], solution: [\"*\"] },\n        { question: \"Get the memory address of a variable `x`.\", template: [ \"ptr = \", { type: \"input\", size: 2, placeholder: \"char\" }, \"x;\" ], solution: [\"&\"] },\n        { question: \"Access the value stored at the address a pointer `ptr` is pointing to.\", template: [ \"value = \", { type: \"input\", size: 2, placeholder: \"char\" }, \"ptr;\" ], solution: [\"*\"] },\n        { question: \"What does a `NULL` pointer point to?\", template: [ { type: \"select\", options: [\"Nothing\", \"Zero\", \"Itself\"] } ], solution: [\"Nothing\"] },\n        { question: \"What type of pointer can point to any data type?\", template: [ { type: \"input\", size: 5, placeholder: \"type\" }, \"*ptr;\" ], solution: [\"void\"] }\n    ],\n    \"Structures\": [\n        { question: \"Define a structure `Person` with an integer `age`.\", template: [ { type: \"input\", size: 7, placeholder: \"keyword\" }, \" Person {<br>&nbsp;&nbsp;&nbsp;&nbsp;int age;<br>};\" ], solution: [\"struct\"] },\n        { question: \"Declare a variable `p1` of type `struct Person`.\", template: [ \"struct Person \", { type: \"input\", size: 3, placeholder: \"var\" }, \";\" ], solution: [\"p1\"] },\n        { question: \"Access the `age` member of the `p1` variable.\", template: [ \"p1\", { type: \"input\", size: 2, placeholder: \"op\" }, \"age = 30;\" ], solution: [\".\"] },\n        { question: \"Use `typedef` to create a new type alias `Person` for `struct Person`.\", template: [ { type: \"input\", size: 8, placeholder: \"keyword\" }, \" struct Person { ... } Person;\" ], solution: [\"typedef\"] },\n        { question: \"Access the `age` member using a pointer `ptr` to a `struct Person`.\", template: [ \"ptr\", { type: \"input\", size: 3, placeholder: \"op\" }, \"age = 30;\" ], solution: [\"->\"] }\n    ],\n    \"Loops\": [\n        { question: \"Write a `while` loop that runs as long as `i` is less than 5.\", template: [ { type: \"input\", size: 6, placeholder: \"loop\" }, \" (i < 5) { ... }\" ], solution: [\"while\"] },\n        { question: \"What keyword skips the current iteration and begins the next?\", template: [ { type: \"select\", options: [\"continue\", \"skip\", \"next\"] } ], solution: [\"continue\"] },\n        { question: \"Which loop type is guaranteed to execute at least once?\", template: [ { type: \"input\", size: 8, placeholder: \"loop type\" }, \" { ... } while (condition);\" ], solution: [\"do-while\"] },\n        { question: \"Create a `for` loop that iterates 10 times.\", template: [ \"for (int i = 0; i \", { type: \"input\", size: 2, placeholder: \"op\" }, \" 10; i++) { ... }\" ], solution: [\"<\"] },\n        { question: \"How do you write an infinite loop using `for`?\", template: [ \"for (\", { type: \"input\", size: 4, placeholder: \"...\" }, \") { ... }\" ], solution: [\";;\"] }\n    ],\n    \"Memory Management\": [\n        { question: \"Allocate memory for 10 integers and store the address in `ptr`.\", template: [ \"ptr = (int*)\", { type: \"input\", size: 7, placeholder: \"func\" }, \"(10 * sizeof(int));\" ], solution: [\"malloc\"] },\n        { question: \"Which header file is required for `malloc` and `free`?\", template: [ \"#include <\", { type: \"input\", size: 8, placeholder: \"header\" }, \">\" ], solution: [\"stdlib.h\"] },\n        { question: \"Free the memory that was previously allocated to `ptr`.\", template: [ { type: \"input\", size: 5, placeholder: \"func\" }, \"(ptr);\" ], solution: [\"free\"] },\n        { question: \"Which function allocates memory and initializes all bits to zero?\", template: [ { type: \"select\", options: [\"calloc\", \"malloc\", \"realloc\"] } ], solution: [\"calloc\"] },\n        { question: \"What function is used to change the size of a previously allocated memory block?\", template: [ \"ptr = \", { type: \"input\", size: 8, placeholder: \"func\" }, \"(ptr, 20 * sizeof(int));\" ], solution: [\"realloc\"] }\n    ],\n    \"File I\/O\": [\n        { question: \"Open a file `data.txt` in read mode.\", template: [ \"FILE *f = \", { type: \"input\", size: 6, placeholder: \"func\" }, \"(\\\"data.txt\\\", \\\"r\\\");\" ], solution: [\"fopen\"] },\n        { question: \"Write the formatted string \\\"ID: 10\\\" to a file pointed to by `f`.\", template: [ { type: \"input\", size: 7, placeholder: \"func\" }, \"(f, \\\"ID: %d\\\", 10);\" ], solution: [\"fprintf\"] },\n        { question: \"Close the file pointed to by `f`.\", template: [ { type: \"input\", size: 7, placeholder: \"func\" }, \"(f);\" ], solution: [\"fclose\"] },\n        { question: \"What file mode is used to open a file for appending?\", template: [ \"fopen(\\\"log.txt\\\", \\\"\", { type: \"input\", size: 2, placeholder: \"mode\" }, \"\\\");\" ], solution: [\"a\"] },\n        { question: \"What is the data type of the variable returned by `fopen`?\", template: [ { type: \"input\", size: 6, placeholder: \"type\" }, \"*f;\" ], solution: [\"FILE\"] }\n    ],\n    \"Preprocessor Directives\": [\n        { question: \"Define a macro `PI` with the value 3.14159.\", template: [ { type: \"input\", size: 8, placeholder: \"directive\" }, \" PI 3.14159\" ], solution: [\"#define\"] },\n        { question: \"Include the standard input\/output header file.\", template: [ { type: \"input\", size: 8, placeholder: \"directive\" }, \" <stdio.h>\" ], solution: [\"#include\"] },\n        { question: \"Conditionally compile a block of code only if `DEBUG` is defined.\", template: [ { type: \"input\", size: 7, placeholder: \"directive\" }, \" DEBUG<br>\/\/ Debug code here<br>#endif\" ], solution: [\"#ifdef\"] },\n        { question: \"What is the primary purpose of `#ifndef` \/ `#define` \/ `#endif` guards in a header file?\", template: [ \"To prevent \", { type: \"input\", size: 10, placeholder: \"issue\" }, \" inclusions.\" ], solution: [\"multiple\"] },\n        { question: \"What directive would you use to undefine a previously defined macro `MAX`?\", template: [ { type: \"input\", size: 7, placeholder: \"directive\" }, \" MAX\" ], solution: [\"#undef\"] }\n    ]\n};\n\ndocument.addEventListener('DOMContentLoaded', function() {\n    const topicSelectionView = document.getElementById('c-ex-topic-selection-view');\n    const exerciseViewsContainer = document.getElementById('c-ex-exercise-views-container');\n\n    \/\/ --- Utility Functions ---\n    function normalizeCode(codeStr) {\n        if (typeof codeStr !== 'string') return '';\n        \/\/ Normalize quotes, trim whitespace, remove trailing semicolons for comparison\n        return codeStr.replace(\/\u201c|\u201d|\u2018|\u2019\/g, '\"').trim().replace(\/;$\/, '');\n    }\n    \n    \/\/ --- View Switching Logic ---\n    function showTopicView(topicKey) {\n        topicSelectionView.style.display = 'none';\n        document.querySelectorAll('.c-ex-exercise-view').forEach(view => view.style.display = 'none');\n        const view = document.getElementById(`c-ex-view-${topicKey}`);\n        if (view) {\n             view.style.display = 'block';\n        }\n    }\n\n    function showTopicSelection() {\n        topicSelectionView.style.display = 'block';\n        document.querySelectorAll('.c-ex-exercise-view').forEach(view => view.style.display = 'none');\n    }\n    \n    \/\/ --- Initialization ---\n    function initialize() {\n        const topics = Object.keys(exercises);\n\n        \/\/ Pre-build all Exercise Views (CSR part)\n        topics.forEach(topic => {\n            const topicKey = topic.replace(\/[^a-zA-Z0-9]\/g, '');\n            const questions = exercises[topic];\n\n            let questionsHTML = '';\n            questions.forEach((q, qIndex) => {\n                let templateHTML = '';\n                let inputCounter = 0;\n                q.template.forEach(part => {\n                    if (typeof part === 'string') {\n                        templateHTML += part; \n                    } else if (part.type === 'input') {\n                        templateHTML += `<input type=\"text\" class=\"c-input\" id=\"c-ex-answer-${topicKey}-${qIndex}-${inputCounter}\" size=\"${part.size || 10}\" placeholder=\"${part.placeholder || '...'}\">`;\n                        inputCounter++;\n                    } else if (part.type === 'select') {\n                        const optionsHTML = part.options.map(opt => `<option value=\"${opt}\">${opt}<\/option>`).join('');\n                        templateHTML += `<select class=\"c-select\" id=\"c-ex-answer-${topicKey}-${qIndex}-${inputCounter}\">${optionsHTML}<\/select>`;\n                        inputCounter++;\n                    }\n                });\n\n                questionsHTML += `\n                    <div style=\"border: 1px solid #E5E7EB; border-radius: 0.5rem;\">\n                        <div style=\"padding: 1rem; border-bottom: 1px solid #E5E7EB;\">\n                             <p style=\"font-weight: 500; margin:0; color: #374151;\">\n                                <span style=\"font-weight: 700; color: #111827;\">Question ${qIndex + 1}:<\/span> ${q.question}\n                            <\/p>\n                        <\/div>\n                        <div class=\"c-code-template\"><pre style=\"margin:0; padding:0; white-space: pre-wrap;\"><code style=\"font-family: monospace;\">${templateHTML}<\/code><\/pre><\/div>\n                        <div id=\"c-ex-feedback-${topicKey}-${qIndex}\" style=\"margin-top: 0.5rem; padding: 0 1rem 0.5rem 1rem;\"><\/div>\n                    <\/div>\n                `;\n            });\n\n            const exerciseViewHTML = `\n                <div id=\"c-ex-view-${topicKey}\" class=\"c-ex-exercise-view\" style=\"display: none;\">\n                    <div style=\"display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start; margin-bottom: 1.5rem; gap: 1rem;\">\n                        <h2 style=\"font-size: 1.5rem; line-height: 2rem; font-weight: 700; color: #111827; margin:0;\" style=\"font-size: 1.5rem; line-height: 2rem; font-weight: 700; color: #111827; margin:0;\" id=\"topic\">${topic}<\/h2>\n                        <button class=\"c-ex-back-btn\" style=\"background-color: #E5E7EB; color: #374151; font-weight: 500; padding: 0.5rem 1rem; border-radius: 0.5rem; border: none; cursor: pointer;\" onmouseover=\"this.style.backgroundColor='#D1D5DB'\" onmouseout=\"this.style.backgroundColor='#E5E7EB'\">Back to Topics<\/button>\n                    <\/div>\n                    <div style=\"display: flex; flex-direction: column; gap: 1.5rem;\">${questionsHTML}<\/div>\n                    <div id=\"c-ex-result-container-${topicKey}\" style=\"text-align: center; margin-top: 2rem;\"><\/div>\n                    <div style=\"text-align: center; margin-top: 1.5rem;\">\n                         <button class=\"c-ex-check-answers-btn\" data-topic-key=\"${topicKey}\" data-topic-name=\"${topic}\" style=\"background-color: #2563EB; color: #FFFFFF; font-weight: 700; padding: 0.75rem 2rem; border-radius: 0.5rem; font-size: 1.125rem; border: none; cursor: pointer; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);\" onmouseover=\"this.style.backgroundColor='#1D4ED8'\" onmouseout=\"this.style.backgroundColor='#2563EB'\">Check Answers<\/button>\n                    <\/div>\n                <\/div>\n            `;\n            exerciseViewsContainer.innerHTML += exerciseViewHTML;\n        });\n\n        \/\/ --- Attach Event Listeners ---\n        document.querySelectorAll('.topic-item-btn').forEach(button => {\n            const topicKey = button.getAttribute('data-topic-key');\n            if (topicKey) {\n                button.addEventListener('click', () => showTopicView(topicKey));\n            }\n        });\n\n        document.querySelectorAll('.c-ex-back-btn').forEach(btn => {\n            btn.addEventListener('click', showTopicSelection);\n        });\n\n        document.querySelectorAll('.c-ex-check-answers-btn').forEach(btn => {\n            btn.addEventListener('click', (event) => {\n                const topicKey = event.currentTarget.getAttribute('data-topic-key');\n                const topicName = event.currentTarget.getAttribute('data-topic-name');\n                const questions = exercises[topicName];\n                let correctCount = 0;\n\n                questions.forEach((q, qIndex) => {\n                    const feedbackContainer = document.getElementById(`c-ex-feedback-${topicKey}-${qIndex}`);\n                    let isCorrect = true;\n                    let inputCounter = 0;\n\n                    q.template.forEach(part => {\n                        if (typeof part === 'object') {\n                            const userInputElem = document.getElementById(`c-ex-answer-${topicKey}-${qIndex}-${inputCounter}`);\n                            const userAnswer = normalizeCode(userInputElem.value);\n                            const correctAnswer = normalizeCode(q.solution[inputCounter]);\n                            if (userAnswer.toLowerCase() !== correctAnswer.toLowerCase()) {\n                                isCorrect = false;\n                            }\n                            inputCounter++;\n                        }\n                    });\n\n                    if (isCorrect) {\n                        correctCount++;\n                        feedbackContainer.innerHTML = `<p style=\"color: #16A34A; font-weight: 600; margin:0;\">\u2713 Correct!<\/p>`;\n                    } else {\n                        \/\/ Reconstruct the correct answer string for display\n                        let correctAnswerHTML = '';\n                        let solutionCounter = 0;\n                        q.template.forEach(part => {\n                            if (typeof part === 'string') {\n                                correctAnswerHTML += part.replace(\/<\/g, \"&lt;\").replace(\/>\/g, \"&gt;\");\n                            } else {\n                                correctAnswerHTML += `<strong style=\"color: #166534;\">${q.solution[solutionCounter]}<\/strong>`;\n                                solutionCounter++;\n                            }\n                        });\n\n                        feedbackContainer.innerHTML = `\n                            <p style=\"color: #DC2626; font-weight: 600; margin:0;\">\u2717 Incorrect.<\/p>\n                            <p style=\"color: #4B5563; margin-top: 0.25rem; margin-bottom: 0.25rem;\">The correct code is:<\/p>\n                            <div class=\"c-code-template\" style=\"background-color: #F0FDF4;\"><pre style=\"margin:0; padding:0; white-space: pre-wrap;\"><code style=\"font-family: monospace;\">${correctAnswerHTML}<\/code><\/pre><\/div>\n                        `;\n                    }\n                });\n\n                const resultContainer = document.getElementById(`c-ex-result-container-${topicKey}`);\n                resultContainer.innerHTML = `\n                    <p style=\"font-size: 1.25rem; font-weight: 700;\">You answered ${correctCount} out of ${questions.length} questions correctly.<\/p>\n                    <p style=\"color: #6B7280; margin-top: 0.25rem;\">Review the feedback above and feel free to try again!<\/p>\n                `;\n            });\n        });\n    }\n\n    \/\/ Run the initialization\n    initialize();\n});\n<\/script>\n\n\n\n\n\n<div class=\"wp-block-group is-layout-constrained wp-block-group-is-layout-constrained\">\n<p>Also Check:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.mygreatlearning.com\/blog\/c-interview-questions\/\">C Interview Questions and Answers<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.mygreatlearning.com\/blog\/top-c-projects\/\">Top C Projects<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.mygreatlearning.com\/blog\/identifiers-in-c\/\">Identifiers in C<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.mygreatlearning.com\/blog\/armstrong-number-in-c\/\">Armstrong Number in C<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.mygreatlearning.com\/blog\/tcs-aptitude-questions-answers\/\">TCS Aptitude Questions and Answers<\/a><\/li>\n<\/ul>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Sharpen your C programming skills with coding practice, exercises, and problems online. Ideal for beginners learning C language and preparing for exams.<\/p>\n","protected":false},"author":41,"featured_media":111776,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"full-width-container","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"disabled","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[25860],"tags":[36889],"class_list":["post-111762","page","type-page","status-publish","has-post-thumbnail","hentry","category-software","tag-c-programming-2"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.3 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>C Programming Practice Questions and Coding Exercises Online<\/title>\n<meta name=\"description\" content=\"Sharpen your C programming skills with coding practice, exercises, and problems online. Ideal for beginners learning C language and preparing for exams.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.mygreatlearning.com\/blog\/c-exercise\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"C Exercises\" \/>\n<meta property=\"og:description\" content=\"Sharpen your C programming skills with coding practice, exercises, and problems online. Ideal for beginners learning C language and preparing for exams.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mygreatlearning.com\/blog\/c-exercise\/\" \/>\n<meta property=\"og:site_name\" content=\"Great Learning Blog: Free Resources what Matters to shape your Career!\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/GreatLearningOfficial\/\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/09\/c-exercise.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1408\" \/>\n\t<meta property=\"og:image:height\" content=\"768\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@Great_Learning\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/c-exercise\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/c-exercise\\\/\"},\"author\":{\"name\":\"Great Learning Editorial Team\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\"},\"headline\":\"C Exercises\",\"datePublished\":\"2025-09-04T10:26:11+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/c-exercise\\\/\"},\"wordCount\":117,\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/c-exercise\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/09\\\/c-exercise.webp\",\"keywords\":[\"C Programming\"],\"articleSection\":[\"IT\\\/Software Development\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/c-exercise\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/c-exercise\\\/\",\"name\":\"C Programming Practice Questions and Coding Exercises Online\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/c-exercise\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/c-exercise\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/09\\\/c-exercise.webp\",\"datePublished\":\"2025-09-04T10:26:11+00:00\",\"description\":\"Sharpen your C programming skills with coding practice, exercises, and problems online. Ideal for beginners learning C language and preparing for exams.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/c-exercise\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/c-exercise\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/c-exercise\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/09\\\/c-exercise.webp\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/09\\\/c-exercise.webp\",\"width\":1408,\"height\":768,\"caption\":\"C Exercise\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/c-exercise\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"C Exercises\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"name\":\"Great Learning Blog\",\"description\":\"Learn, Upskill &amp; Career Development Guide and Resources\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"alternateName\":\"Great Learning\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\",\"name\":\"Great Learning\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"width\":900,\"height\":900,\"caption\":\"Great Learning\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/GreatLearningOfficial\\\/\",\"https:\\\/\\\/x.com\\\/Great_Learning\",\"https:\\\/\\\/www.instagram.com\\\/greatlearningofficial\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/in.pinterest.com\\\/greatlearning12\\\/\",\"https:\\\/\\\/www.youtube.com\\\/user\\\/beaconelearning\\\/\"],\"description\":\"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.\",\"email\":\"info@mygreatlearning.com\",\"legalName\":\"Great Learning Education Services Pvt. Ltd\",\"foundingDate\":\"2013-11-29\",\"numberOfEmployees\":{\"@type\":\"QuantitativeValue\",\"minValue\":\"1001\",\"maxValue\":\"5000\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\",\"name\":\"Great Learning Editorial Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"caption\":\"Great Learning Editorial Team\"},\"description\":\"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.\",\"sameAs\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/\",\"https:\\\/\\\/in.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/Great_Learning\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCObs0kLIrDjX2LLSybqNaEA\"],\"award\":[\"Best EdTech Company of the Year 2024\",\"Education Economictimes Outstanding Education\\\/Edtech Solution Provider of the Year 2024\",\"Leading E-learning Platform 2024\"],\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/author\\\/greatlearning\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"C Programming Practice Questions and Coding Exercises Online","description":"Sharpen your C programming skills with coding practice, exercises, and problems online. Ideal for beginners learning C language and preparing for exams.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.mygreatlearning.com\/blog\/c-exercise\/","og_locale":"en_US","og_type":"article","og_title":"C Exercises","og_description":"Sharpen your C programming skills with coding practice, exercises, and problems online. Ideal for beginners learning C language and preparing for exams.","og_url":"https:\/\/www.mygreatlearning.com\/blog\/c-exercise\/","og_site_name":"Great Learning Blog: Free Resources what Matters to shape your Career!","article_publisher":"https:\/\/www.facebook.com\/GreatLearningOfficial\/","og_image":[{"width":1408,"height":768,"url":"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/09\/c-exercise.webp","type":"image\/webp"}],"twitter_card":"summary_large_image","twitter_site":"@Great_Learning","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.mygreatlearning.com\/blog\/c-exercise\/#article","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/c-exercise\/"},"author":{"name":"Great Learning Editorial Team","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad"},"headline":"C Exercises","datePublished":"2025-09-04T10:26:11+00:00","mainEntityOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/c-exercise\/"},"wordCount":117,"publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/c-exercise\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/09\/c-exercise.webp","keywords":["C Programming"],"articleSection":["IT\/Software Development"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.mygreatlearning.com\/blog\/c-exercise\/","url":"https:\/\/www.mygreatlearning.com\/blog\/c-exercise\/","name":"C Programming Practice Questions and Coding Exercises Online","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/c-exercise\/#primaryimage"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/c-exercise\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/09\/c-exercise.webp","datePublished":"2025-09-04T10:26:11+00:00","description":"Sharpen your C programming skills with coding practice, exercises, and problems online. Ideal for beginners learning C language and preparing for exams.","breadcrumb":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/c-exercise\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mygreatlearning.com\/blog\/c-exercise\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/c-exercise\/#primaryimage","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/09\/c-exercise.webp","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/09\/c-exercise.webp","width":1408,"height":768,"caption":"C Exercise"},{"@type":"BreadcrumbList","@id":"https:\/\/www.mygreatlearning.com\/blog\/c-exercise\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/www.mygreatlearning.com\/blog\/"},{"@type":"ListItem","position":2,"name":"C Exercises"}]},{"@type":"WebSite","@id":"https:\/\/www.mygreatlearning.com\/blog\/#website","url":"https:\/\/www.mygreatlearning.com\/blog\/","name":"Great Learning Blog","description":"Learn, Upskill &amp; Career Development Guide and Resources","publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"alternateName":"Great Learning","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mygreatlearning.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization","name":"Great Learning","url":"https:\/\/www.mygreatlearning.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","width":900,"height":900,"caption":"Great Learning"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/GreatLearningOfficial\/","https:\/\/x.com\/Great_Learning","https:\/\/www.instagram.com\/greatlearningofficial\/","https:\/\/www.linkedin.com\/school\/great-learning\/","https:\/\/in.pinterest.com\/greatlearning12\/","https:\/\/www.youtube.com\/user\/beaconelearning\/"],"description":"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.","email":"info@mygreatlearning.com","legalName":"Great Learning Education Services Pvt. Ltd","foundingDate":"2013-11-29","numberOfEmployees":{"@type":"QuantitativeValue","minValue":"1001","maxValue":"5000"}},{"@type":"Person","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad","name":"Great Learning Editorial Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","caption":"Great Learning Editorial Team"},"description":"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.","sameAs":["https:\/\/www.mygreatlearning.com\/","https:\/\/in.linkedin.com\/school\/great-learning\/","https:\/\/x.com\/https:\/\/twitter.com\/Great_Learning","https:\/\/www.youtube.com\/channel\/UCObs0kLIrDjX2LLSybqNaEA"],"award":["Best EdTech Company of the Year 2024","Education Economictimes Outstanding Education\/Edtech Solution Provider of the Year 2024","Leading E-learning Platform 2024"],"url":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"}]}},"uagb_featured_image_src":{"full":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/09\/c-exercise.webp",1408,768,false],"thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/09\/c-exercise-150x150.webp",150,150,true],"medium":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/09\/c-exercise-300x164.webp",300,164,true],"medium_large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/09\/c-exercise-768x419.webp",768,419,true],"large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/09\/c-exercise-1024x559.webp",1024,559,true],"1536x1536":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/09\/c-exercise.webp",1408,768,false],"2048x2048":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/09\/c-exercise.webp",1408,768,false],"web-stories-poster-portrait":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/09\/c-exercise-640x768.webp",640,768,true],"web-stories-publisher-logo":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/09\/c-exercise-96x96.webp",96,96,true],"web-stories-thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/09\/c-exercise-150x82.webp",150,82,true]},"uagb_author_info":{"display_name":"Great Learning Editorial Team","author_link":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"},"uagb_comment_info":0,"uagb_excerpt":"Sharpen your C programming skills with coding practice, exercises, and problems online. Ideal for beginners learning C language and preparing for exams.","_links":{"self":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/pages\/111762","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/comments?post=111762"}],"version-history":[{"count":11,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/pages\/111762\/revisions"}],"predecessor-version":[{"id":111791,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/pages\/111762\/revisions\/111791"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media\/111776"}],"wp:attachment":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media?parent=111762"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/categories?post=111762"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/tags?post=111762"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}