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

Lesson 2: Hello World

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

The Most Basic Program — Hello World

When learning programming, the first thing you write is Hello World. It contains every essential element of the C language in one tiny program.
#include<stdio.h>

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

Understanding the Program Structure

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

Try It Yourself — Hello World

Change the text inside printf("...") and display your own message.
my_hello.c
Output
Click "Run" to execute...
Advertisement

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!
← Home
Back to Course Index
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, the main() function is the entry point (starting point) of the program.

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

Hello (with newline)
Hello (no newline)
Error

printf does not add a newline unless you include \n. To add 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 file, required for using functions like printf and scanf.

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