Explanation of the above Program

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

Sections Description
/**                     
* file: sum.c
* author: you
* description: program to find sum.
*/
It is the comment section and is part of the description section of the code. 
#include<stdio.h> Header file which is used for standard input-output. This is the preprocessor section.
#define X 20 This is the definition section. It allows the use of constant X in the code.
int sum(int y) This is the Global declaration section includes the function declaration that can be used anywhere in the program.
int main() main() is the first function that is executed in the C program.
{…} These curly braces mark the beginning and end of the main function. 
printf(“Sum: %d”, sum(y)); printf() function is used to print the sum on the screen.
return 0; We have used int as the return type so we have to return 0 which states that the given program is free from the error and it can be exited successfully.
int sum(int y) 
{
 return y + X;
}
This is the subprogram section. It includes the user-defined functions that are called in the main() function.

Steps involved in the Compilation and execution of a C program:

  • Program Creation
  • Compilation of the program
  • Execution of the program
  • The output of the program

Read more about Compiling a C Program Compilation – Behind the Scenes

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