Hello World

Lesson 4
Author : Afrixi
Last Updated : January, 2023
C - Programming Language
This course covers the basics of programming in C.

“Hello, World!” is a simple program that is often used as the first program when learning a new programming language, including C. The program simply displays the text “Hello, World!” on the screen.

Here’s the code for the “Hello, World!” program in C:

#include <stdio.h>

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

Let me break down what each part of this code does:

#include <stdio.h>: This line includes the standard input/output library, which provides functions for input and output in C. int main(): This is the main function of the program, which is where the program starts running. The int before main() indicates that the function returns an integer value. {: This is the start of the code block for the main function. printf("Hello, World!\n");: This line uses the printf function to display the text “Hello, World!” on the screen. The \n at the end of the string is an escape sequence that represents a newline character, which adds a line break after the text. return 0;: This line indicates that the main function should return an integer value of 0. This is conventionally used to indicate a successful execution of the program. }: This is the end of the code block for the main function.

To run this program, you need to compile it using a C compiler and then execute the resulting program. There are different ways to do this depending on your operating system and the tools you have installed. Once you have compiled the program, you should be able to see the output “Hello, World!” on your screen.