In this tutorial we will discuss about writing our very first computer program with the language of C.
Okay it’s the time to write our First C program. We will use Codeblocks as our C Compiler . Now you must be wanted to know what is the thing Compiler is???? Your brain is storming now we guess after hearing the word Compiler. We will not going into deep about compilers. Because it’s not the main topic of the tutorial . Just to give you a hint A compiler is a special program that processes statements written in a particular programming language and turns them into machine language or "code" that a computer' processor uses.
Okay below the screenshot gives us the look of our first program. This is our very first program in C . Let's explore it

Save the program with the name: Hello.c . You can save it as any of your desired name. This one is just the name which came across our mind. But remember the name should be a hint of your work. Such as a program of addition can’t be named rose or butterfly. It should be add or addition or something which will represent that this is a program of mathematical addition.
Okay now its the time to go across the syntax we used in our program. You need not worry about the syntax much now. After sometime you will become familiar with the syntaxes.
#include<stdio.h>
With this line of code we include a file called stdio.h. (Standard Input/Output header file). This file lets us use certain commands for input or output which we can use in our program. (Look at it as lines of code commands) that have been written for us by someone else). For instance it has commands for input like reading from the keyboard and output commands like printing things on the screen.
int main()
The int is what is called the return value (in this case of the type integer). Where it used for will be explained further down. Every program must have a main(). It is the starting point of every program.The round brackets are there for a reason, in a later tutorial it will be explained, but for now it is enough to know that they have to be there.
{}
The two curly brackets (one in the beginning and one at the end) are used to group all commands together. In this case all the commands between the two curly brackets belong to main(). The curly brackets are often used in the C language to group commands together. (To mark the beginning and end of a
group or function.).
printf(“Hello OutsBook\n”);
The printf is used for printing things on the screen, in this case the words: Hello OutsBook. As you can see the data that is to be printed is put inside round brackets. The words Hello OutsBook are inside inverted commas, because they are what is called a string. (A single letter is called a character and a series of characters is called a string). Strings must always be put between inverted commas. The \n is called an escape sequence. In this case it represents a newline character. After printing something to the screen you usually want to print something on the next line. If there is no \n then a next printf command will print the string on the same line.
Commonly used escape sequences are:
- \n (newline)
- \t (tab)
- \v (vertical tab)
- \f (new page)
- \b (backspace)
- \r (carriage return)
After the last round bracket there must be a semi-colon. The semicolon shows that it is the end of the command. (So in the future, don’t forget to put a semicolon if a command ended).
return 0;
When we wrote the first line “int main()”, we declared that main must return an integer int main(). (int is short for integer which is another word for number). With the command return 0; we can return the value null to the operating system. When you return with a zero you tell the operating system that there were no errors while running the program.
To understand this thing things properly about return types you have to learn about functions.which will be discussed in the later classes.So now we are not going to deep about function to keep it simple.
Compile
If you have typed everything correct there should be no problem to compile your program. By pressing F9 the Code Blocks will will compile and run the program u just typed and will create and show Hello.exe file
Congratulations!!!!!
You have just made your first program in C.
Comments in your program
The Hello program is a small program that is easy to understand. But a program can contain thousands of lines of code and can be so complex that it is hard for us to understand. To make our lives easier it is possible to write an explanation or comment in a program. This makes it much easier to understand the code. (Even if you did not look at the code for years).These comments will be ignored by the compiler at compilation time.
Comments have to be put after // or be placed between /* */ .
Here is an example of how to comment the Hello source code :

Indentation
As you can see the printf and return statements have been indented or moved to the right side. This is
done to make the code more readable. In a program as Hello, it seems a stupid thing to do. But as the programs become more complex, you will see that it makes the code more readable.
So, always use indentations and comments to make the code more readable. It will make your life much easier if the code becomes more complex.
Okay Thanks for being with us in this little tutorial about writing your first program in C. Plenty of tutorial will come later.
Now try to solve problem:
Prepared by: Parag Paul