πŸ‡―πŸ‡΅ ζ—₯本θͺž | πŸ‡ΊπŸ‡Έ English

Lesson 2: Hello World

Write your first C program, Hello World. A clear walkthrough of the compile and run flow.

The Simplest Program — Hello World

The classic first program is Hello World. Despite being tiny, it packs in every essential piece of a C program.
#include<stdio.h>

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

Understanding the Program Structure

Click any line to see what it does.
#include<stdio.h>
int main(void){
printf("Hello World!\n");
return 0;
}
↑ Click any line above to see an explanation.

Try It Yourself — Hello World

Change the text inside printf("...") and print your own message.
my_hello.c
Output
Click "Run" to execute...
πŸ’‘ A few things to try

Related Lessons

Getting Started
Lesson 3: Variables
What is a variable in C? Learn int, double, and char with clear diagrams.
Getting Started
Lesson 4: printf & scanf
How to use printf and scanf in C. A complete reference of format specifiers.
Reference
C Cheat Sheet
Quick reference for printf, operators, types, and more. Bookmark this page!
← Previous lesson
Lesson 1: What is Programming
Next lesson →
Lesson 3: Variables

Review Quiz

Check your understanding of this lesson!

Q1. Which function runs first in a C program?

start()
main()
init()

In C, main() is the program's entry point β€” it's where execution starts.

Q2. What is the output of printf("Hello");?

Hello (with newline)
Hello (no newline)
Error

printf doesn't add a newline on its own β€” you have to include \n. For a newline, write printf("Hello\n");.

Q3. What does #include <stdio.h> do?

Runs the program
Imports the standard I/O library
Declares a variable

stdio.h is the standard I/O header β€” you need it to use functions like printf and scanf.

Share this article
Share on X (Twitter) Share on Facebook