C Programs | IT Developer
IT Developer

C Programs



Share with a Friend

C Program: Hello World

C Program: Hello World

C

#include <stdio.h>   // Standard Input Output library

// Main function: program execution starts here

int main() {

    // Print message to screen

    printf("Hello, World!\n");

   

    return 0; // Exit status of program

}

Output

 
OUTPUT :
Hello, World!

Explanation (Line by Line)

  1. #include <stdio.h>
    • This is a preprocessor directive.
    • It tells the compiler to include the Standard Input Output header file (h).
    • This header file provides functions like printf() and scanf().

  2. int main()
    • Every C program must have a main()
    • Execution always begins from main().
    • The int before main means this function returns an integer value (status code).

  3. printf("Hello, World!\n");
    • printf() is a standard output function used to display text on the screen.
    • "Hello, World!" is the text string to display.
    • \n is an escape sequence that means "new line".
    • So after printing the message, the cursor moves to the next line.

  4. return 0;
    • Ends the main()
    • Returns 0 to the operating system, which means the program executed successfully.

Using Turbo C (Old Windows IDE):

  • Open file → Compile (Alt+F9) → Run (Ctrl+F9).