Basic Structure of a C Program

Structure of C program

It is necessary to be aware of proper structure flow of programming language you are writing code in. Not following proper structure of program may lead to error. Structure of a language gives a basic idea of the order of sections in a program. Here we will discuss the different section of structure.

structure of c

Basic Structure of C Program

A C Program have the following entities that define structure of the program –

  1. Preprocessor commands
  2.  Functions
  3. Variables
  4. Statements and Expressions

Sample code

Let’s take an example for exploring this section. Following is the code in C language to calculate the area of circle whose radius is 5.

#define PI 3.1416
float area (float r);
int main(void)
//Example of variables
float r = 5;
printf("Area: %.2f",area(r)); // This statement will print two digit after the point
return 0;

//Example of function
float area(float r)
//example of statements & Expression
return PI * r * r;


Area: 78.54

Prime Course Trailer

Related Banners

Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others

Checkout list of all the video courses in PrepInsta Prime Subscription

Checkout list of all the video courses in PrepInsta Prime Subscription

2 comments on “Basic Structure of a C Program”

    • Debashish Mahato

      basically printf is for output so in this case (.2) will print only two number after the value of AREA suppose we wrote (.4) then it will print upto 4 number after the value of AREA
      so our output woul;d be like this Area:78.54.
      the value of r is 5 so it would be multiplied with PI*R*R.