Basic Structure Of A C Programming Language - Computer Free Knowlege Basic Structure Of A C Programming Language | Computer Free Knowlege

0
A C program consists of one or more functions. The function main () is the first function to be executed in a C program. The body of the function is surrounded by braces. The left brace indicates the start of the function and the matching right brace indicates its end. At the beginning of a C program, header files are included in a statement that informs the C compiler to include its declarations in the user's program. Each statement of C language is terminated with a semicolon. To introduce the structure of C program we will start with a very simple program that will print the message:

#include
#include
main ()
{
       printf("Pakistan");
}

Output:
Pakistan

The # sigh indicates that this is an instruction for the compiler. stands for stander input/output header and the word include informs the C compiler to include the declarations in the file stdio.h in the user's program. One item included in this header is a declaration of the function prints (). Almost any program needs to perform I/O operations. Therefore, most of the C programs must be preceded by this instruction.

A C program consists of one or more functions. C uses functions as the building blocks of its programs. A function performs a single well-defined task. Every C program must have the function main () which is the first section to be executed when the program runs. The body of the function is surrounded by braces. The left brace indicates the start of the body of the function the matching right brace indicates the end of the body of the function.

The body of the function in my program consists of a single statement printf () which ends with a semicolon. Printf () is the standard output function. The text to be printed is enclosed in double quotes. A statement in C is terminated with a semicolon. Therefore, a semicolon is used at the end of printf () statement. The effect is the the string "Pakistan" is printed on the screen when the program runs.

Post a Comment

 
Top