Syntax of C Program
Syntax of C Program
#include<stdio.h> //Header File
void main(){
printf(“Hello”);//prints 'Hello'
printf(“\n I am Devil”);//prints 'I am Devil' in New Line
}
Here is the simple example of Syntax in C program
First Line is #include<stdio.h> is the HeaderFile.
Then after void is the data type which returns nothing.
Then Main() is the Function. C program always start from here.
And Next Printf is the function which prints the string which is provide in the brackets.
In the next printf function I used a ‘\n’ which is used for new Line.
More Important thing is in the program is semicolon ‘;’- It used to end the current statement.
Here, Statement means one line of code wrote abobe.
For ex, printf(“Hello”) -> so this is a single statement and we must provide the ‘;’ at the end of statememt.
If I forgot to put semicolon at end of statement then compile takes this as single Statement and gives a compile time error because of the syntax.
Comments
Post a Comment