Hello world program π
π₯ Basic Hello World Program in C π
Program :
C
#include <stdio.h>
int main()
{
printf("Hello, World!");
return 0;
}
π Explanation of Each Line (In Detail)
1️⃣ #include <stdio.h>
#include → This is a preprocessor directive.
It tells the compiler to include the standard input-output header file.
<stdio.h> contains built-in functions like:
printf() → used to print output
scanf() → used to take input
π Without this line, printf() will not work.
2️⃣ int main()
main() is the starting point of every C program.
The program execution always begins from this function.
int means this function will return an integer value.
3️⃣ { } (Curly Braces)
These define the body of the function.
All statements of the program are written inside these braces.
4️⃣ printf("Hello, World!");
printf() is an output function.
It prints the message written inside double quotes ("") on the screen.
✔ "Hello, World!" → This is a string constant (you studied constants earlier π)
✔ ; → Semicolon is used to terminate the statement in C.
5️⃣ return 0;
It ends the main() function.
0 means the program executed successfully.
The value is returned to the operating system.
π§ Tokens Used in This Program
Token Type Example
Keyword int, return
Identifier main, printf
String Constant "Hello, World!"
Special Symbol { } ( ) ; # < >
Header File stdio.h
▶️ Output of Program
Hello, World!
π Flow of Execution
- Preprocessor includes stdio.h
- Compiler starts from main()
- printf() prints message
- return 0; ends the program
Comments
Post a Comment