C Programming/C Basics

C Write First Program

Updated on January 8, 2026
1 min read

Basic Structure of C Program

Every C program follows a fixed structure. Understanding this structure helps you read, write, and debug C programs easily.

Basic Structure of a C Program

#include <stdio.h>

int main() {
    printf("Hello, World!");
    return 0;
}

Parts of a C Program

1. Documentation Section

  • Used to write comments about the program.
  • Helps explain the purpose of the program.
// This program prints Hello World

2. Link Section

  • Includes header files using #include.
  • Header files contain predefined functions.
#include <stdio.h>

3. Definition Section

  • Used to define constants using #define.
#define PI 3.14

4. Global Declaration Section

  • Variables and functions declared outside main().
  • These can be used throughout the program.
int count;

5. main() Function

  • Program execution starts from main().
  • Every C program must have one main() function.
int main() {
    return 0;
}

6. Declaration Section

  • Variables declared inside main().
int a, b;

7. Executable Section

  • Contains program logic and statements.
a = 10;
b = 20;
printf("%d", a + b);

8. Return Statement

  • Sends control back to the operating system.
return 0;

Example Program with Full Structure

c
1#include <stdio.h>
2#define PI 3.14
3
4int main() {
5    int r = 5;
6    float area;
7
8    area = PI * r * r;
9    printf("Area = %f", area);
10
11    return 0;
12}

Important Points

  • Every statement ends with a semicolon ;
  • C is case-sensitive
  • main() is compulsory
  • Header files are required for built-in functions
C Write First Program | C Programming | Learn Syntax