Writing Your First C Program
Before we dive into the details, let’s look at a simple C program that prints “Hello, World!” on the screen. This is traditionally the first program written in any language.
Example: “Hello, World!” in C
#include <stdio.h> // Header file for standard input-output functions
int main() { // Main function – entry point of a C program
printf(“Hello, World!\n”); // Prints text to the console
return 0; // Indicates that the program executed successfully
}
📌 Output:
Hello, World!
Understanding the Structure of a C Program
Every C program follows a specific structure. Let’s break it down:
Basic Structure of a C Program
#include <header_file> // Preprocessor directive
int main() { // Main function
// Statements inside the function
return 0; // Return statement
}