Tuesday, August 18, 2020

7.1.2 Structure of C Program

 C Program Structure



Your First C Program

/* Header file declaration */
#include<stdio.h>
/* Main function declaration */
int main()
{
/* Printing message to screen */
printf("Hello GEC , PATAN!");
/* returning */
return 0;
}

Hello GEC , PATAN!


  • The <stdio.h> header file in the first line is included in the program. This is a standard input / output header file which handles input and output in the program.
  • Preprocessor directives are used to include them in the program. 
  • After this the main () function has been started. 
  • The execution of the program starts with the main function itself.
  • All the instructions are written in the same function. 
  • The main function is shown by the start and end curly brackets. 
  • All the instructions inside these curly brackets are executed.
  • The main function has been define with int type. This is a standard. 
  • The main function is to always return an integer value. If you do not return a value return from the main () function in the program, then at the end of the program, we write return 0 statement.
  • In the main function, you can also pass arguments that are called command line arguments. 
  • For more information about these, read C Language Command Line Arguments in My Coding Blocks Tutorial.


No comments:

Post a Comment

Please do not any spam link in Comment Box