C PROGRAM • PROGRAM STRUCTURE & OUTPUT

Display Hello World

Understand the smallest complete C program and trace how printf() produces output.

Beginnermain()printf()Header files

PROBLEM UNDERSTANDING

Input and expected output

Sample input
No input required
Sample output
Hello, World!

C PROGRAM

Complete program

hello-world.c
#include <stdio.h>

int main(void)
{
    printf("Hello, World!\n");
    return 0;
}

INTERACTIVE LEARNING

Debug this program line by line

Watch the active line, variables and output.

This program does not require input. Select Start to trace it.

CURRENT STEP

Select Start to trace this program.

VARIABLES

ScopeNameValue
Not started

CALL STACK

main()

PROGRAM OUTPUT

Waiting to run…
0%Step 0 of 0

PROGRAM EXPLANATION

Algorithm and explanation

  1. Start the main() function.
  2. Call printf() with the required message.
  3. Return 0 to finish successfully.

stdio.h declares printf(). Execution begins in main(), printf() writes the message, and return 0 reports successful completion.

EFFICIENCY

Time and space complexity

Time complexity

O(1)

Auxiliary space

O(1)

DEBUGGING CHECKLIST

Common mistakes

Check this

Writing Printf instead of printf; C is case-sensitive.

Check this

Missing the semicolon after printf().