C Program Structure

Posted By on September 27, 2016

Download PDF
Characteristics of C
Global Variables in C

A C program basically has the following form:

  • Preprocessor Commands
  • Type definitions
  • Function prototypes — declare function types and variables passed to function.
  • Variables
  • Functions

We must have a main() function.

A function has the form:

type function_name (parameters)
				 local variables
				 C Statements

If the type definition is omitted C assumes that function returns an integer type. NOTE: This can be a source of problems in a program.

So returning to our first C program:

  /* Sample program */ 
				 printf( "I Like C \n");
				 exit ( 0 );


  • C requires a semicolon at the end of every statement.
  • printf is a standard C function — called from main.
  • \n signifies newline. Formatted output — more later.
  • exit() is also a standard function that causes the program to terminate. Strictly speaking it is not needed here as it is the last line of main() and the program will terminate anyway.

Let us look at another printing statement:

The output of this would be:



Characteristics of C
Global Variables in C

Download PDF

Posted by Akash Kurup

Founder and C.E.O, World4Engineers Educationist and Entrepreneur by passion. Orator and blogger by hobby

Website: http://world4engineers.com