Header Ads

Header ADS

First C program

First Program in C :


Basically a C program may consists of following parts:-

Preproccesor Commands

Functions

Variables

Statements and Expressions

Comments




Let us look at a simple code  which prints " WELCOME TO DYNAMIC CODING".


#include<stdio.h>
void main()
{
printf("WELCOME TO DYNAMIC CODING");
}

Lets us look at the various parts of the above program:-

  • Line 1 :-   #include<stdio.h> here  '#' is the preproccesor directive which includes the 'stdio.h' library before the program compilation. 'stdio.h' stands for standard input output library which contains input output functions like printf(),scanf(),etc.
  • Line 2 :- void main()  here main() is said to be the entry point of the program from where the actual compilation of the program starts. void is the return type of the main() , which means that main() is returning nothing. () is the parentheses which contains the parameters of main function if any. If it is empty then it means that main function didn't have any parameter. We can also write main(void) which means the same as main().
  • Line 3 & Line 5 :-  '{' and '}' are the start and end point of the main() function respectively. Its is called as block. Each and every line written in the block belongs to the same function.
  • Line 4 :- printf("WELCOME TO DYNAMIC CODING"); here printf() is the output function which prints everything which is written inside it. ';' semicolon denotes the end of the statement.

Output:-

WELCOME TO DYNAMIC CODING

Note:- 
Every C program must contain atleast one function which is main() function .




This blog is contributed by Shivam Shukla .
Please leave a feedback in comment section

 



No comments

Powered by Blogger.