
Here is a simple Hello World program in C:
#include <stdio.h>
int main(void)
{
printf("Hello, World!\n");
return 0;
}1. Include the standard input/output header
#include <stdio.h>This makes declarations for standard input/output functions available, including printf(), which prints text to the screen.
2. Define the main function
int main(void)main is where the program starts executing. int means the function returns an integer status code, and void means it takes no parameters.
3. Start the function body
{The opening curly brace marks the beginning of the instructions inside main.
4. Print the message
printf("Hello, World!\n");printf() displays the text inside the quotation marks. \n moves the cursor to a new line. The semicolon ; ends the statement.
5. Indicate successful completion
return 0;This ends main and returns the status code 0 to the operating environment, indicating success.
6. End the function body
}The closing curly brace marks the end of main.
Output:
Hello, World!
Log in to add a comment.
Arman Arman
Nice Article