Hello World Program in C

Definition:

The Hello World program is the first program that beginners learn in C. It is used to display a simple message on the screen and helps understand the basic structure of a C program.

Explanation:

This program demonstrates the use of the printf() function to display output. Every C program starts execution from the main() function.


Program: Hello World

Explanation: This program displays the words Hello and World on the screen using two printf() statements.


#include<stdio.h>

main()
{

    printf("Hello, World!");

    getch();

}

Output:

HelloWorld

Program: Using \n (New Line)

Explanation: This program uses the \n escape sequence to print text on separate lines.


#include <stdio.h>

main()
{
    printf("Hello\n");
    printf("World");

    getch();
}

Output:

Hello
World

Program: Using \t (Tab Space)

Explanation: This program uses the \t escape sequence to insert a horizontal tab space between words.


#include <stdio.h>

    main()
{
    printf("Hello\tWorld");

    getch();
}

Output:

Hello    World

Practice Exercises

Task 1: Write a C program to print your name.

Goal: Learn how to display text using printf().
💡 Hint: Use one printf() statement.
💡 Show Solution

#include <stdio.h>

    main()
{
    printf("Rahul");

    getch();
}

Output
Rahul
Task 2: Write a C program to print your city name.

Goal: Practice the printf() function.
💡 Hint: Display one string.
💡 Show Solution

#include <stdio.h>

    main()
{
    printf("Aurangabad");

    getch();
}

Output
Aurangabad
Task 3: Write a C program to print "Welcome to C Programming".

Goal: Learn to display a complete sentence.
💡 Hint: Use one printf() statement.
💡 Show Solution

#include <stdio.h>

    main()
{
    printf("Welcome to C Programming");

    getch();
}

Output
Welcome to C Programming