Structure of 'C' Programming Language

The structure of a C program can be broadly divided into several components. Here's a basic overview:


1.Documentation Section:


This section is optional and is used for adding comments and documentation about the program.


Comments in C are written using /* */ for multiline comments and // for single-line comments.


Header Files:


Header files are included at the beginning of the program to provide information to the compiler about functions that will be used in the program.


Commonly used header files include #include << /span>stdio.h > for standard input and output functions.


Main Function:


Every C program must have a main function, which is the entry point of the program.

The execution of the program begins from the main function.


Data Declarations:


Variables are declared to store data. Data types (int, float, char, etc.) are specified for each variable.


Example
        int age;
        float salary;
        char grade;

Executable Statements:


These are statements that perform actions. They include assignments, calculations, and function calls.


Example
            age = 25;
            salary = 50000.50;
            grade = 'A';
        

Control Structures:


C provides various control structures like loops (for, while, do-while) and conditional statements (if, else, switch) to control the flow of the program.


Example
            if (age >= 18) {
                printf("You are eligible to vote.\n");
            } else {
                printf("You are not eligible to vote.\n");
            }            
        

Functions:


C programs are often organized into functions. The main function is required, and you can define additional functions to modularize the code.


Example
            void displayMessage() {
                printf("Hello, World!\n");
            }            
        

Comments:


Comments are used to explain the code and make it more readable. They are ignored by the compiler.


Example
            // This is a single-line comment
            /* This is a
                 multiline comment */
        

Preprocessor Directives:


These are lines in your program that begin with a # symbol. They are processed before the actual compilation and are used for macro definitions and conditional compilation.


Example
            #define PI 3.14
        

These components collectively form the structure of a C program. The actual structure and complexity may vary depending on the specific requirements of the program.