Hello world in c programming language
C Language mein pehla program jo traditionally likha jata hai woh "Hello, World!" program hota hai.
Is program mein aap ek chhota sa program likhkar computer screen par "Hello, World!" likhne ka amal karate hain. Yahan ek simple "Hello, World!" program diya gaya hai:
#include
int main() {
printf("Hello, World!\n");
return 0;
}
Yeh program kuch mahatvapurna points ko dikhata hai:
1. `#include
2. `int main()`: Har C program ka execution `main` function se shuru hota hai. Yeh function ek `int` (integer) type ka return value deta hai. `main` function ka body `{}` ke bheetar hota hai.
3. `printf("Hello, World!\n");`: `printf` function ka istemal "Hello, World!" ko console par print karne ke liye kiya gaya hai. `\n` newline character ko represent karta hai, jisse ke text ek nayi line par shuru ho.
4. `return 0;`: `main` function se 0 return karne se program ko yeh signal milta hai ki woh sahi tarah se run hua hai. Isse program ko successful execution ka pata chalta hai.
Is program ko ek C file (for example, `hello.c`) mein likhkar compile aur run karne ke liye, aapko ek C compiler ka upayog karna hoga. Command line se, aap ise is tarah compile aur run kar sakte hain:
1. Open a command prompt or terminal.
2. Navigate to the directory where you saved your `hello.c` file.
3. Compile the program using the following command (assuming you have GCC installed):
```
gcc -o hello hello.c
```
Yeh command `hello.c` file ko compile karke `hello` naamak executable file bana degi.
4. Run the program using the following command:
./hello
Aapke screen par "Hello, World!" likha hua dikhega. Yeh program C Language ke basic syntax aur structure ko samajhne mein madad karta hai.