Hello world program in C

The Hello World program is the first step in learning any programming language, and it is also one of the simplest. All that is required is to display the message Hello World on the screen. We’ll look at how to write a simple Hello World program in C in this post. The Hello World program is a standard program that will help you learn the basics of a language. It helps you understand how to write the bare minimum of code to create a program, compile it, and run it. The Hello World program will eliminate the complex steps required to develop applications in programming languages.

The Hello World program in C outputs a simple statement. Whatever is enclosed in double quotes within the printf() statement is printed as such. printf() is a library function that displays formatted output on the screen. The Hello World program is one of the simplest programs you will learn, and it also serves as the first step in learning any programming language. Simply showing the message Hello World on the screen will do the trick. Let’s examine the program and attempt to comprehend the lingo used within it.

Hello World Program

A simple c program is written to demonstrate how the c program works. This C program contains the bare minimum of code required to create a program that demonstrates how it works. This program includes the fundamental coding practise required to create any C program. This program will not run if any of the lines are removed. This program prints ‘Hello World’ when run. This simple example demonstrates how C programs are created and executed.


// First Program to print Hello World
int main()
	printf("Welcome to Hello World!");
	return 0;


Welcome to Hello World!


The preprocessor command #include instructs the compiler to include the contents of the stdio.h (standard input and output) file in the program.

The stdio.h file contains functions for taking input and displaying output, such as scanf() and printf().

The program will not compile if you use the printf() function without including #include <stdio.h>.

The C program execution begins with the main() function.

printf() is a library function that displays formatted output on the screen. In this program, printf() prints the text Hello, World! to the screen.

The program “Exit status” is indicated by the return 0; statement. Simply put, this statement marks the end of the program.

Compile the Hello World Program

The Hello World programme is written in a text editor and saved as c. The text file cannot be run. The code written in the C programming language should be converted into machine-readable code. The C language compiler will convert a C programme stored in a text file into an object file. The object file will contain machine level code that the computer can understand and execute. To use the C Program, you must have the C compiler installed on your computer. GCC is a popular C language compiler that is available for both Windows and Linux. Create an object file from the C programme written in text file using the C compiler.

gcc hello.c

The above command compiles the C programme and generates an object file named hello.o. The object file is a machine-readable file that the computer can understand. The binary programming instructions will be stored in the file. Humans cannot understand the object file.

Run the Hello World Program

The object file can be executed in the operating system directly. The object files are stored in a file with extention of .o or .obj depends on the operating system you use. You can run the file directly in the command prompt.

> ./hello


> sh hello

Leave a Reply

Your email address will not be published. Required fields are marked *