Menu
×
Tutorials Ms Word Tutorial Ms Excel Tutorial Ms PowerPoint Tutorial C Language Tutorial C++ Tutorial C Sharp Tutorial Visual Basic Tutorial HTML Tutorial CSS Tutorial JavaScript Tutorial WordPress Tutorial
     ❯   

ADVERTISEMENT

Structure of C Program

Hello World Example

The following things make up a C program:

  • Preprocessor Commands
  • Functions
  • Variables
  • Statements and Expressions
  • Comments

This is a simple code that will print Hello World.

#include <stdio.h>
int main() {
   /* my first program in C */
   printf("Hello, World! \n");
   return 0;
}
C Programming

Take a look at the different parts of the program above:

Line 1: It tells the C compiler to include the stdio.h file before it starts to compile the code in the first line of the program, which is called #include <stdio.h>.

Line 2: That line,  int main() is the program’s main function. It’s where everything begins.

Line 3: The compiler will not use the next line, /*…*/. The code calls these lines  comments for that reason.

Line 4: Another function in C,  printf() is used to show the message “Hello, World!” on the screen.

Line 5: The function main() ends with the line  return 0; which returns the value 0.

Spread the love
Scroll to Top
Scroll to Top