C Program Structure

Understanding the programming structure of the C language is essential before creating C language programs, as it allows you to understand what's happening at each step in your C program. In this tutorial, we'll learn about the structure of C programs and how C programs are created.

When we learn any programming language, we first understand the pattern of writing programs. If you don't know the pattern of writing programs, you won't understand any code properly.

Let's understand the structure of C programming with a basic example.

C Program Structure 

The structure of a C program is where we can understand all the steps and code.

Let's understand with an example:

Example: Simple "Hello World" Program in C

When we create a C program, many parts in it are very important to understand.

Like - Preprocessor Commands, Functions, Variables, Statements & Expressions, Comments

Let's understand all these parts with an example.

#include <stdio.h>
void main()

   /* Hello World program in C in hindi */
   printf("Hello, World in C programming n"); 

In the above program, we have created a very simple C program. Now let's understand the structure of this program:

  1. Preprocessor Commands: These are the commands at the beginning of the program, such as #include <stdio.h>. We call this a preprocessor command. It includes the library file in the program so that we can use the functionality of that library.

  2. Main Function: In the second line, we have used void main(). This means the execution of our C program starts from here. void main() is a parent function that handles the status of the program, whether it will execute or fail.

  3. Comments: In C programming, we use comments to mark instructions or code lines to understand which part of the program is being used for what purpose. We use symbols like /*...*/ to write comments. For example: /* This is my first program of C language*/.

  4. Curly Braces { }: After the void main() function, we have opened and closed curly braces { }. This signifies a block of the function where all the functionality of the function resides. Whenever we create a function, we use curly braces { } to mark the block of the function. After all the work of the function is done, we close the function block.

  5. printf() Function: In the next line, we have used printf() function. printf() is a function provided by the C programming library, which is pre-made and can be used simply by writing. Its job is to display the statement on the screen. If you want to display any value, you can use printf() in C language.

This way, you've understood all the parts of the C programming structure, which is necessary if you're going to write C language programs.

Let's understand another example where we will use int main():

#include <stdio.h>
int main()
   /*Hello Word program in C langauge */
   printf("Hello, World! n");
   return 0;


In the above example, we replaced void main() with int main(). int main indicates that at the end of our function execution, we must return an integer value. We use return 0 it at the end of the program to indicate successful execution. "0" is the standard for successful execution, returning an integer value.

In the end, return 0 is written, terminating the main() function and returning a value of 0. In C programming, the main() the function can have either void or int as a return type.

Please Share

Recommended Posts:-