C – Language

C Syntax

Example Program

Let’s look at the basic C program 👇

#include <stdio.h>

int main() {

printf(“Hello, World!”);

return 0;

}

Now let’s break it down and understand each part clearly 👇

  1. #include <stdio.h>
  • This is a preprocessor directive.
  • It tells the compiler to include the Standard Input Output library before compilation.
  • This library contains functions like printf() and scanf().
    👉 Without this line, you can’t use input/output functions.
  1. int main()
  • Every C program must have one main() function.
  • Execution of the program starts from the main() function.
  • The keyword int means that the function returns an integer value (normally 0).
  1. { } (Curly Braces)
  • These curly braces define the body of the main function.
  • All the code to be executed is written inside these braces.
  1. printf(“Hello, World!”);
  • printf() is used to display text or output on the screen.
  • “Hello, World!” is a string, and it will appear on the output screen.
  • Every statement in C ends with a semicolon ( ; ).
  1. return 0;
  • This line returns a value from the main function to the operating system.
  • 0 indicates that the program ended successfully without errors.

 Simple Explanation

#include → add library
 main() → starting point
 { } → code area
 printf() → output
 return 0; → program finished correctly