Make your first program in C

Here is the simple C program to start with

So, as I posted before, I wish you have downloaded DevC++.
If not, click to the link below and have a look.
So, lets start with our first program.
First, we will add header file in our program.
#include<stdio.h>
#include<conio.h>
What is a header file
Header file is nothing but the pre determined file with ‘.h’ extension which contains all the common functions declaration and definition that we commonly perform.
Don’t go in so deep, we will fight with this later. Now you just take it as a line that helps us to use the printing or getting input function and all the essential functions of C.
After adding header files, add main()
main()
The main function
Every program in c or even c++ must have a function call main. As the name suggest, its the main function of the program. The compiler starts compiling from the main function.
After main, add curly braces
{
}
Curly braces
The another element of C program is curly braces. It acts like a border and shows the area of that fuction.
After that, to print or display anything on your program screen, use printf.
printf(“Lets Brogram!”);
printf(); is a built in function of <stdio.h> header file. You can write what you want to display inside ” “, its important to note that we have to write in ” “, because if we write it without them, compiler will take it as a variable. We will understand that in variable concept.
Add a getch(); at the end of the program, before curly braces.
Your program will look like this:
#include<stdio.h>
#include<conio.h>
main()
{
printf(“Lets Brogram!”);
getch();
}
If you have query about why we added getch(); then I am going to post the reason and will attach its link here.
After writing these program, save the file with extension ‘.c’ to specify that its a C program file.
After saving, just go to execute->compile, once it get compile without any error, click on execute->run.
It will execute like this:
Lets Brogram!
Stay tuned for more contents!
See you next time();

Related Posts with Make your first program in C