C basic syntax rules and uses

C basic syntax rules and uses

C Basic Syntax is very easy. In this tutorial, I have explained it in a systematic manner.

We will focus on the syntax and the program structure in C.

C Basic Syntax

[c]
#include<stdio.h>
#include<conio.h>
void main()
{
printf(“C Language.”);
getch();
}
[/c]

Output

C Language.

Explaination of above code

<stdio.h> is the preprocessor library. which have some function inside it, like printf(), sprintf(), sscanf(), scanf(), vprintf(), vsprintf and many more, that’s we include this library before we start the program. the full form of stdio.h is Standard Input Output file.

<conio.h> Header is the console input-output header file. It is also have many function like clrscr(), getch(), getche(), textcolor().

The void is the keyword. Function uses void keyword if they won’t return anything. main() is the function from where the execution starts in c program. Compiler or interpreter start checking of the program from main() method, that’s why main is the important part of the program. So, you must have the main inside the program.

printf() is the function, which is used to print any value on console output.

getch() is the String type function, which will for any input at run time. so that you can see your output easily.

Comments in C Language

We have two types of Comment in C Language.

Single line comment

Example: – // this is a Syntax of Single Line comment.

[c]
//this is comment in c
[/c]

Multiple Line comments

Example

[c]
/*this is comment in c
for multiple line */
[/c]

After some days, when you try to understand the program, these comments help you to understand the program.

Comments are part of good documentation.