Structure of C Program with example
Example: Below C program to find the sum of 2 numbers:
C
// Documentation /** * file: sum.c * author: you * description: program to find sum. */ // Link #include <stdio.h> // Definition #define X 20 // Global Declaration int sum( int y); // Main() Function int main( void ) { int y = 55; printf ( "Sum: %d" , sum(y)); return 0; } // Subprogram int sum( int y) { return y + X; } |
Output
Sum: 75
Structure of the C Program
The basic structure of a C program is divided into 6 parts which makes it easy to read, modify, document, and understand in a particular format. C program must follow the below-mentioned outline in order to successfully compile and execute. Debugging is easier in a well-structured C program.
Contact Us