Structure of C program
Before starting understanding the Structure of C program, we need to know what are instructions?
Instructions
Instructions are very much similar to sentences/statements in English language. It is the combination of various tokens, character set elements to perform a desired task/output to help a program make it complete.
OR
Instructions in C are the commands in the program that will instruct C compiler to perform specific tasks or actions. Whenever we write a C instruction, we are telling C compiler to do a task for us.
Structure of C program
Following are the categories of instructions:
- Declaration instructions
- Input/output instructions
- Assignment instructions
- Arithmetic/logical instructions
- Control instructions
1- Declaration instructions
These are used to declare different kind of variable further to be used by the C program.
Eg:- we want to make a program and declare the variable suppose, we want to write the area of rectangle. So the declaration is
int A, B, Area;
OR
int l, b, area;
We want to add two numbers, then the declarations is
int A, B, sum;
2- Input/output instructions
Input instructions are used for supplying values to the variables as declared in declarative instructions.
Eg:- (Statically supplying the values to the variables)
A=10;
B=20;
Where the values of variables are fixed.
(for dynamically supplying the value)
then we use a C library function called scanf( )
output instructions are used for printing the output after the execution of instructions.
Then we use a C library function called printf( );
3- Assignment instructions
These are used for assigning the values in proper order to the variables.
int A, B, C;
printf(“Enter the first number”);
scanf(“%d”,&A);
printf(“Enter the second number”);
scanf(“%d”,&B);
printf(“Enter the third number”);
scanf(“%d”,&C);
4- Arithmetic instructions / Logical instructions
These are used for applying the arithmetic formula or logic to solve the problems.
Eg:- we need to give a logical instruction to out program
area=l * b;
OR
area = A * B;
5- Control instructions
These are used to control the flow of execution of the program.
Data types in C
Ranges of Data types in C
Our first C program
stdio.h
Standard input output header file
This header files contains the definition of standard
Input output functions used by a C program.
Eg:- printf( ); scanf( );
| |
| |
| |
output input
conio.h
Console input ouput header file
This header file contains the definition of standard input output functions used by C program related to console input output devices.
Eg:- keyboard for input
monitor for output
The function needed for supplying the input data via keyboard and to get output data via monitor are defined inside <conio.h> library header file.
clrscr( ); Clear the screen
getch( ); Get character
void main( )
C compiler starts its compilation from main( ).
Before compilation these is another process known as pre-processing takes place.
During pre-processing, the header files are to be declared in this section.
Some important points to be noted while you make any program
- C program is case sensitive
- All the statements are end with semicolon ( ; )
- You must have to include header files
- Space values are ignored in C.



0 Comments