• Home
  • 1.1 C Hello World

1.1 C Hello World

View Categories

1.1 C Hello World

< 1 min read

Table of Contents

A C program starts execution from the main() function. This basic program demonstrates the standard structure of a C program, including a header file, the main() function, a statement, and the return statement.

#include <stdio.h>

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

    return 0;
}

Example Output #

Hello, World!

Explanation #

The header file:

#include <stdio.h>

provides the declaration of printf(), which is used to write formatted output to the standard output stream.

The program entry point is:

int main()

main() returns an int value to the environment that started the program.

The output statement is:

printf("Hello, World!\n");

printf() writes the specified text to standard output. The escape sequence \n moves the output position to the next line.

The statement:

return 0;

terminates main() and returns 0, conventionally indicating successful program termination.

The braces { and } define the body of the main() function, while the semicolon ; terminates each statement.

Powered by BetterDocs

Leave a Reply

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