First C Program
Hi,
Here we will write the first, simplest and smallest C program.
Procedure:
1. Start the Dev-C++ IDE and create New->Source File from the File menu item.
2. Save this file with name "HelloWorld.c" from Save As option from File menu.
3. Type the snippet of code given below.
4. Save the program by Ctrl+S.
5. Compile the program by F9.
6. Run the program by F10.
7. In-case you require Compile and Run on single click, use F11.
8. The output will be "Hello World".
Note: The underline and other information shown in output screen is appended automatically by Dev-Cpp. Its not the part of your program but is beneficial as of now. In later programs we will remove it.
Line by Line Explanation of Code:
Line 1: "stdio.h" is the standard input output header file. The definition of printf and scanf (most commonly used input output functions is declared here).
Line 2: "conio.h" is the console input output header file. To display output on the console screen, this header file is used.
Line 3: main() is the initial point of program execution. Every program has a main() function which signifies starting of program. Here return type of main() is void, i.e. it returns nothing.
Line 4 and 6: They are the braces which constitute a block also known as body of the function.
Line 5: It is the printf() statement which prints output on the screen. Anything written inside the "" (double quotes) is printed as it is on the screen. Printf is used to print formatted string also.
This is all about the Hello World program.
You can try replacing "Hello World" string to print your own name or something else to.
Next post will be regarding "Keywords in C".
Till then
Happy Learning!!!
Prateek
Here we will write the first, simplest and smallest C program.
Procedure:
1. Start the Dev-C++ IDE and create New->Source File from the File menu item.
2. Save this file with name "HelloWorld.c" from Save As option from File menu.
3. Type the snippet of code given below.
#include<stdio.h>
#include<conio.h>
void main()
{
printf("Hello World");
}
4. Save the program by Ctrl+S.
5. Compile the program by F9.
6. Run the program by F10.
7. In-case you require Compile and Run on single click, use F11.
8. The output will be "Hello World".
Note: The underline and other information shown in output screen is appended automatically by Dev-Cpp. Its not the part of your program but is beneficial as of now. In later programs we will remove it.
Line by Line Explanation of Code:
Line 1: "stdio.h" is the standard input output header file. The definition of printf and scanf (most commonly used input output functions is declared here).
Line 2: "conio.h" is the console input output header file. To display output on the console screen, this header file is used.
Line 3: main() is the initial point of program execution. Every program has a main() function which signifies starting of program. Here return type of main() is void, i.e. it returns nothing.
Line 4 and 6: They are the braces which constitute a block also known as body of the function.
Line 5: It is the printf() statement which prints output on the screen. Anything written inside the "" (double quotes) is printed as it is on the screen. Printf is used to print formatted string also.
This is all about the Hello World program.
You can try replacing "Hello World" string to print your own name or something else to.
Next post will be regarding "Keywords in C".
Till then
Happy Learning!!!
Prateek
Comments
Post a Comment