Explain structure of a C program using one sample program.
Answers
Answered by
1
A C program. A C program is a set of functions, data type definitions and variable declarations contained in a set of files. A C program always start its execution by the function with name main . This means that the defined variables and functions are not remembered when processing another file.
Answered by
0
Answer:
Following is the general structure of the C program:
#include<header files>
#define MACRO statements
int main() //main function
{
...........
............
return 0;
}
Explanation:
Let's understand this structure:
- The first line of any C program is always the inclusion of header files. Header files are pre-defined files that have user input and output functions. An example of header files is stdio.h, conio.h and math.h, etc.
- In the second line, we can define the macros of the program. Macros are the repetitive and constant values that are not needed to change frequently like the value of PI or charge of electron etc.
- Then we write our main function from where the execution of the program will begin.
- Inside the main function, we can write all types of statements that are required for our program.
- Lastly, a return 0 statement is returned since our main is int type. You can also write your main as void.
#SPJ3
Similar questions