Back to Course
Getting Started

First C program and Its Syntax

Your First C Program

#include <stdio.h>

int main() {
    printf("Hello, World!");
    return 0;
}

Breaking Down the Syntax

  • #include <stdio.h> — a preprocessor directive that includes the Standard Input Output library, needed for functions like printf().
  • int main() — every C program starts execution from the main() function.
  • { } — curly braces mark the beginning and end of a function's body.
  • printf("Hello, World!"); — prints text to the console. Every statement ends with a semicolon.
  • return 0; — indicates the program ended successfully.

Compiling and Running

Save the file as hello.c, then compile and run it using GCC:

gcc hello.c -o hello
./hello

Ready to master real-world C Programming development?

Learn C Programming hands-on with mentor-led, live sessions.

Explore Course