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.

Similar Reads

Sections of the C Program

There are 6 basic sections responsible for the proper execution of a program. Sections are mentioned below:...

Structure of C Program with example

Example: Below C program to find the sum of 2 numbers:...

Explanation of the above Program

...

Conclusion

Below is the explanation of the above program. With a description explaining the program’s meaning and use....

FAQs for Structure of C Program

In this article points we learned about the structure of the C Program are mentioned below: 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. Debugging is easier in a well-structured C program. There are 6 sections in a C Program that are Documentation, Preprocessor Section, Definition, Global Declaration, Main() Function, and Sub Programs. There are certain steps while compilation and executing of C program as mentioned below: Creation of Program Compilation of the program Execution of the program Output of the program...

Contact Us