First program

Here is the basic syntax of C,it’s a program to Print Hello.

#include <stdio.h> 
int main() 
{
 
printf("Hello");
 
return 0;
}

Output : Hello

Header Files Inclusion: The first and foremost component is the inclusion of the Header files in a C program.
A header file is a file with extension .h which contains C function declarations and macro definitions to be shared between several source files.

#include<header_name.h>

it’s contain the necessary file for the program.

#include<stdio.h> 
#include<math.h> 

Main Function Declaration: The next part of a C program is to declare the main() function.this is the Main Function, it will execute first in program.

The syntax to declare the main function is:

int main()
{
return 0; 
}

Body: Body of a function in C program, refers to the operations that are performed in the functions. It can be anything like manipulations, searching, sorting, printing, etc.

Simply the space in which we are going to write our Program.

int main() 
{ 
<body>
return 0;
}

Return: The last part of any C program is the return statement. The return statement refers to the returning of the values from a function. This return statement and return value depend upon the return-type of the function. For example, if the return type is void, then there will be no return statement. In any other case, there will be a return statement and the return value will be of the type of the specified return-type.

<return_type> main ()

#include<stdio.h>
int main() 
{ 
return 0;
} 
#include<conio.h>
#include<stdio.h>
void main() 
{ 
getch();
}

in the first example the return type is int so we have to give return.while in the second example the return type is void so we don’t have to return anything, but we are giving getch() in that because it will execute the program in the background and not show in screen, for catch or hold the result we have to use getch() it comes under header file conio.h .

so overall

1st line #include<stdio.h> is including the file stdio.h to our program

2nd line is including the conio.h file to our program

3rd & 4 rth line starting of the main function

5th line print(“HEllo wORLD”); is a printing statement that will print whatever is written in-between ” ” , to the screen

6th line closing of the main function with its return type if int main then return 0; and if void then we have to use getch() for showing outputs.

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
Best Wordpress Adblock Detecting Plugin | CHP Adblock