C language was developed by Dennis Ritchie in 1972. Initially it was developed as system language for writing Operating Systems. It is a powerful general purpose programming language. Operating Systems, databases, compilers can be developed in this programming language.

Structure of a C Program

Structure of any program means that any program can be written in this structure only. Any other flow of program will lead to compilation error.

#include<stdio.h>           /* header */
int main()                  /* Main() */
{
int x=5                     /* variable declaration */
printf("%d",x);            /*body */
return 0;                         /*return */

Components of above programs are following

1. Including Header Files

This is the first and most important component of the C Program. #include<stdio.h> includes standard input output header file. A header file is a file with extension .h which contains C function declarations and macro definitions to be shared between several source files.

2. Main Method Declaration

Next component in the structure above is declaring main function.

Main method can be declared

int main()
{}

3. Variable Declaration

after declaring the main method we need to define some variables which are needed for our program

In C language no variable can be used with out declaration. Before using any variable we need to declare variables.

we can define variable by first writing its data type and then variable name. A syntax of defining a variable is given below

int a;
char b;
float c;

You’ll learn more about different data types in C later.

4. Body

In this part of the structure you need to define your functions and operations as code. This can be anything like printing, inserting or anything.

An example of a body is given below.

printf("%d", a)
print("%f",c);

5. return statement

In this part we define what do we want the program to return. This return statement and value of return depends on the function we defined in our program. There are various types of returns. Void return means it returns nothing.

return can be declared as below

return 0;

Important Notice

If you’re a college student and have skills in programming languages, Want to earn through blogging? Mail us at geekycomail@gmail.com

For more Python related blogs Visit Us Geekycodes . Follow us on Instagram.

Leave a Reply