C Program Structure Online Test/Quiz 1

Structure of a C Program Explained with Realtime Examples

/*---------------------------------------------------
    Program: Documentation Section Example
    Description: This program shows how comments work
---------------------------------------------------*/

#include <stdio.h>

int main() {

    printf("This program demonstrates documentation comments.\n");

    return 0;
}

#include <stdio.h>   // Header file included

int main() {

    printf("This program demonstrates the link section using stdio.h\n");

    return 0;
}

#include <stdio.h>

#define PI 3.14   // Constant defined
#define MAX 10    // Another constant

int main() {

    printf("Value of PI = %.2f\n", PI);
    printf("Value of MAX = %d\n", MAX);

    return 0;
}

#include <stdio.h>

int counter = 10;   // Global variable

int main() {

    printf("Global counter value = %d\n", counter);

    return 0;
}

#include <stdio.h>

// User-defined function
void displayMessage() {
    printf("Welcome to C Program Structure!\n");
}

int main() {

    displayMessage();   // Calling the function

    return 0;
}

#include <stdio.h>

int main() {

    printf("This is the main() function where execution starts.\n");

    return 0;
}

#include <stdio.h>

int main() {

    int a = 5;      // Variable declared
    int b = 10;     // Another variable
    int sum;        // Variable for result

    sum = a + b;

    printf("Sum = %d\n", sum);

    return 0;
}

#include <stdio.h>

int main() {

    int x, y, result;

    printf("Enter two numbers: ");
    scanf("%d %d", &x, &y);

    result = x + y;   // Executable logic

    printf("Result = %d\n", result);

    return 0;
}

Why This C Program Structure Quiz Is Useful?

  • Helps beginners understand the order of a C program
  • Matches B.Tech and diploma syllabus
  • Covers interview-focused concepts
  • Easy language, beginner-friendly explanations
  • Supports practice for competitive exams
  • Each section includes a complete example program
  • Helps you memorize the exact structure used in real coding

This quiz will make you confident about writing any C program from scratch.

Topics Covered in This Learning Page

  • Documentation Section
  • Link Section
  • Definition Section
  • Global Declaration Section
  • User-Defined Functions
  • main() Function
  • Declaration Part
  • Executable Part

And each topic contains a full, working program to help you practice.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top