First C Program – Detailed Explanation With Header File
Easiest way to Understand C Programming
1.Open Dev C++ and go to File > New > Empty File.
2.Write the following C code and save the file as test (File > Save File as):
1. #include <stdio.h>
2.
3. int main() {
4. printf(“Hello World!”);
5. return 0;
6. }
This program is written in the C language and is intended to print the phrase “Hello World!” to the console.
The code begins with the line
1.#include <stdio.h>,
which tells the compiler to include the contents of the standard input/output header file.
This header file contains the definitions and declarations of functions used for input and output, such as the printf() function used in this program.
2.A blank line. C ignores white space. But we use it to make the code more readable.
3.main() function. {}
The main() function is the entry point of all C programs, and is where the program execution begins. {Program Body}
4.The next line is a call to the printf() function, which prints the string “Hello World!” to the console.
5.Finally, the return 0 statement tells the program to return a value of 0 to the calling function, which indicates that the program has executed successfully.
6.} – Program Body Close.