C Program - Hello World



Here is an example of a "Hello, world!" program in C:



#include <stdio.h> 

This line includes the "standard input/output" library, which contains the functions used for input and output (such as printf).


int main() 

This line declares the main function of the program, which is where execution starts. The int before main indicates that the function returns an integer value.


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

This line calls the printf function from the standard input/output library, which prints the string "Hello, world!" to the console. The \n at the end of the string is a newline character, which causes the cursor to move to the next line after the string is printed.


return 0; 

This line is the return statement of the main function. Since the main function has an int return type, it must return a value. In this case, the value 0 is returned, which generally indicates that the program completed successfully.


Note that the "Hello, World!" program is a simple program, mostly used to test or understand the basic structure of a C program.



Image by 200 Degrees from Pixabay 

Popular posts from this blog

Insight: The Great Minimal OS Showdown—DietPi vs Raspberry Pi OS Lite

Running AI Models on Raspberry Pi 5 (8GB RAM): What Works and What Doesn't

Raspberry Pi Connect vs. RealVNC: A Comprehensive Comparison