C Program Structure

 

Structure of the C Program


It is also known as the Skeleton of C Program. How C Program Looks Like. It is having so many sections.


A typical C program is divided into the following sections:



Let Understand this structure with suitable example given below:

Simple Example: C Program to Add Two Numbers

// 1. Preprocessor Directive
#include <stdio.h>

// 2. Global Declaration (optional)
int sum(int a, int b);  // function prototype

// 3. main() Function
int main() 
{

    // 4. Variable Declarations
    int num1 = 10, num2 = 20, result;

    // 5. Executable Statement
    result = sum(num1, num2);  // calling function

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

    return 0;
}

// 6. Function Definition
int sum(int a, int b) {
    return a + b;
}


Listen Podcast Link Introduction to C Program Structure


Today's Evening Plan





Comments