write the general structure of a c program
Answers
Answer:
he Unix operating system using the B language, out of which C evolved. The B language lacked certain features that led to the introduction of C. These features constituted the part of the C program upon which it was is built.
Parts of C program-
# include <stdio.h> – This command is a preprocessor directive in C that includes all standard input-output files before compiling any C program so as to make use of all those functions in our C program.
int main() – This is the line from where the execution of the program starts. The main() function starts the execution of any C program.
{ (Opening bracket) – This indicates the beginning of any function in the program (Here it indicates the beginning of the main function).
/* some comments */ – Whatever is inside /*——-*/ are not compiled and executed; they are only written for user understanding or for making the program interactive by inserting a comment line. These are known as multiline comments. Single line comments are represented with the help of 2 forward slashes “//——”.
printf(“Hello World”) –The printf() command is included in the C stdio.h library, which helps to display the message on the output screen.
getch() – This command helps to hold the screen.
return 0 –This command terminates the C program and returns a null value, that is, 0.
} (Closing brackets)- This indicates the end of the function. (Here it indicates the end of the main function)
Before we move towards an example, you should revise the Syntax of C.
Example of C Program Structure
The “Hello World!” example is the most popular and basic program that will help you get started with programming. This program helps you display the output “Hello World” on the output screen.
With the help of this example, we can easily understand the basic structure of a C program.
Explanation:
Answer:
Basic Structure of C Program
Document section.
Preprocessor/link Section.
Definition section.
Global declaration section.
Function declaration section.
Main function.
User-defined function section.
Explanation: