Page Nav

HIDE

Grid

GRID_STYLE

Classic Header

{fbt_classic_header}

Search This Blog

Notes:

latest

03_Basic Structure of C programming



Basic Structure of C program

#include<stdio.h>

int main()

{

printf("Global Institute of Technology");

return 0;

}


#include<stdio.h>


The line #include<stdio.h> is called a preprocessor directive. The line which begins with the # sign is a preprocessor directive. It tells the compilers preprocessor that the contents of the file stdio.h should be included at the place where #include appears. The file stdio.h is called a header file and it contains the declaration needed to use standard input/output operations like printf() , scanf() .



int main()


The function main() is required in all C programs. The main() is the starting point of a C program. It is independent of whether it is at the beginning, at the end or by the middle of the program. Its content is always the first to be executed when a program starts and by default it is the last when the program ends. main goes followed by a pair of parentheses () because it is a function.

In this case the main function is of integer type.


() and { }


In C, all functions are followed by a pair of parenthesis () that, optionally, can include arguments within [e.g void sum(int a, int b) ]. The content of the main function follows immediately to its header enclosed between braces {  }, as in our example. The code inside the braces {  } is program statements that are to be executed.



printf("Global Institute of Technology");


The first statement printf("Global Institute of Technology"); causes the text Global Institute of Technology, to be printed on the standard output device (often known as console). 


Here, printf() is a C function that prints the text in an output device. The printf() function is defined in the stdio.h header file. 


Every statement in C is to be closed with semicolon i.e. ;  



return 0;


Every program in C return some value and in this case this program doesn’t return any value. This program is of integer type. So, it has to be returned some integer value and it returns void that means nothing or zero.



Download the PDF file




-----------------------------------------------------------------------------------------------------------------------------
The End
-----------------------------------------------------------------------------------------------------------------------------

No comments

If you have any doubts, Please let me know,

Click here to show more posts