Writing Your First C Program

Writing Your First C Program

#include<stdio.h>//line 1
#include<conio.h>//line 2
void main()     //line 3
{        //line 4
clrscr();   //line 5
printf("Hello World!! This is my first C Program");     //line 6
getch();      //line 7
}         //line 8

Explanation of Program

line 1 : This line incude header file stdio(standard inut output ) which contains predefined function printf() and scanf(). # is a preprocessor directive and include is a command.

line 2 : This line include header file conio(Console input output) which contains predefined functions clsrscr() and getch().

line 3 :This is main function or we can say a driver function .this is the part from where our program runs that is why it is also called as the driver function. Every code of a program ,directly or indirectly,comes inside the main function.

void used in front of main function is the return type of main function . Every function returns some value so main function returns value of void type.

line 4 : Opening braces of a function.

line 5 : Predefined function for clearing console output screen.

line 6 : Predefined function to print message on screen.

line 7 : Predefined function to accept a single character which in turn holds the console output screen until a key is pressed.

line 8 : Closing braces of a function.

Note -> ';'  is a statement terminating symbol which denotes the end of a statement ,expressions,etc.

Note -> The another symbol '//' is used to add comments in our code. anything followed by // is not readable by compiler ,there is no meaning of it to compiler .it is only used for the reference of programmer.


Output Of this Program :


Hello World!! This is my first C Program






Go For Live Demo

Comments

Popular posts from this blog

Coding tips for Developers

Master Data Structure & Algorithms in Python

How to Start with Coding: A Beginner's Guide