Explain the Format of C language


C programming is a general-purpose, procedural, imperative computer programming language. In C language, we see that

  • Statements are terminated with semicolons.
  • C is case sensitive
  • Indentation is ignored by the compiler.
  • Strings are placed in double quotes.
  • Library functions are lowercase.
  • Newlines are handled via

Format of C

The format of C programming language is explained below −

Semicolons

Semicolons are very important in C.

It tells the compiler, where one statement ends and the next statement begins.

If we fail to place the semicolon after each statement, you will get compilation errors.

Case Sensitivity

C is a case sensitive language. Although, int compiles, "Int”, "INT” or any other variation will not be functional in C.

All C keywords are lowercase.

Comments are not necessary

Even though comments are not important, but, it is a good practice to begin a program with a comment which indicates the purpose of the program, like author and the date the program was written.

Example program

Following is the C program to calculate the circumference of a circle by using the C format method −

The formula for circumference of circle= 2*PI*R.

Where, R is the radius of a circle and PI is a constant whose value is PI3.415.

Example

#include<stdio.h> //library function are lower case
#include<conio.h>
#define PI 3.1415
main ( ){
   float c, r; //statements are terminated with semicolon
   printf ("enter radius of circle"); //strings are placed in double
   quotes
   scanf ("%f", &r);
   c = 2 * PI * r;
   printf ("Circumference = %f", c);
   getch ( );
}

Output

When the above program is executed, it produces the following result −

Enter radius of circle 1
Circumference=6.2830

Updated on: 11-Mar-2021

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements