Tuesday, July 7, 2015

Types of C Instructions

As we all know that a Program is a set of Instructions.Different Instructions helps us  to achieve different task in the program.In previous post i described you about the simple C program,Now lets discuss over C instructions.
Generally there are three types of instructions:
1) Arithmetic Instructions:Such instructions are used to perform arithmetic operations on constants      and variables.
Example:

                     a=i.j.k(x+y)                   // a normal arithmetic expression                                                                                                  a=i*j*k*(x+y)                // a C statement.

2)Type Declaration: This is used to declare the type of the variable.These statements are usually    written at the beginning of main( ) function.
 NOTE: The order in which we define the variables is sometimes important sometimes not.
Example:
                   int i=5,j=2;
                   float a=5.3,b=a-2.6;    //these above two examples are acceptable however the below  declaration is not

                  (float b=a-2.6,a=5.3; ) is incorrect as here we are trying to use variable a ,even before defining it.

NOTE:In order to use any variable in instruction it must be defined in memory first . 
3)Control Instructions: These set of instructions are used to control the sequence of execution of  various statements.
There are four types of  control instructions in  C.
1) Sequence Control
2) Selection and Decision Control.
3)Loop or Repetition Control.
3)Case Control.

All these types you can see in programming part

No comments:

Post a Comment