Skip to main content

Basic C Program

Very basic C Program

Follwing is a Very basic C program that prints "Hello, World!" to the console:

// Include Header files
#include "stdio.h" //printf, scanf etc

// Start of C application
int main()
{
// Print to Console/Terminal
printf("Hello World");

// Return Success
return 0;
}

Components of C Program

This program simply prints the message "Hello, World!" to the console when executed. This program has the following components

  • The #include directive tells the compiler to include the contents of the stdio.h header file, which contains functions for input and output, such as printf.

  • The int main() function is the entry point of the program. It is a special function that is called when the program starts. The int at the beginning indicates that the function returns an integer value.

  • The printf() function is used to print a string to the console. The string is enclosed in quotation marks and followed by a semicolon to indicate the end of the statement.

  • The return 0; statement indicates that the program has completed successfully and returns a value of 0 to the operating system. In C, a return value of 0 typically indicates success, while a non-zero value indicates an error.