C102: First program


Hello world program is the first program built when learning programming language.

#include<stdio.h>

// main function for hello world program
int main(){
  printf("Hello world");
  return 0;
}

First line include the contents of stdio header file into our program. This header file contains printf() output function which display a formatted string on the screen,,

Second line is left blank optionally just to make program neat and easy to read,

Third line is the comment that explains the purpose of the function.It also may include other information about parameters and type of value the function returns.

Fourth line is header for the main function, it tells compiler the beginning of the main function, it also tells compiler name of the function, its parameters and return values. We also have the opening curly bracket { which means the function body starts here.

Fifth line is output statement. Output is performed by the prinf() function. this function takes a string as parameter. The string is enclosed in double quotation. output statement ends with a semicolon.

Sixth line is a return statement. This statement return a value at the end of the function or before laving the function. It simply saying that the execution of the program is successful to your operating system.

Seventh line is the end of of the main function body. this is indicated by the closing curly bracket.


Comments

Popular posts from this blog

Drawing Simple Pie Chart

VB.net connecting to SQL Server

VB.net