## Monday, 24 February 2014

### What are the instruction set in C Language ?

To understand and for clear idea of question What are the instructions set in C Language ? we need clear idea on what is an instruction and instruction set ?

Instruction Set- An instruction set is a set of instruction in program that execute and compile  by compiler

Instruction is an order that writes in program for specific purpose. Each instruction is a sequence of  0s and 1s that describes a physical operation the computer is to perform (such as \”Add\”) and, depending on the particular instruction type.

There are three types of instructions set available in C. Those are

• Type Declaration Instruction
• Arithmetic instruction
• Control Instruction

Type Declaration Instruction

This type of Instruction use to declare the what type of variables in c program.Any Variable used in c program must be Declare before  using it any statement.The type Declaration instruction is written at the starting of the main() function.

Example-

Int pr,;

Float w,r;

Int p=10,r=20;

Arithmetic Instruction

Arithmetic instructions are used to perform arithmetic operations on variables and constants

The variables and constants on which arithmetic operation is done by arithmetic operators are called operands.

Example 1:
int a = 5, b = 10, c;
c = a + b;
Here,
a, b and c are called operands
=, + are called as operators

A C arithmetic instruction consist of variable name on the left hand side of = and variable name & constant on the right hand side of =. The variable and constant appearing on the right hand side of = are connected by arithmetic operators like +,-,* and /

Example 2:
int a;
float b, c, d;
a = 10;
b = 0.05;
c = 1.5;
d = a +b * c;
Here,
a is integer variable.
b, c and d are real variables.
= is the assignment operator.
+ and * are arithmetic operators.
10 is integer constant.
0.05 and 1.5 are real constants.

Control Instructions

In c-Control instructions enable us to specify the order in which the various instructions in a program are to be executed by the computer. In other words the control instructions used to control the sequence of program.

We write a program to perform a particular task. The program might be addition of two numbers, subtraction of two number or division of two numbers. Let us suppose that we need to write a program to perform all the above three operations i.e. addition, subtraction and multiplication. Writing three different programs is not feasible. If we do so, then for addition, subtraction and division we need to run the program separately. Instead of doing this, we can include decision control statement. Using this we can decide within the program whether to perform addition, subtraction or division. Thus program becomes efficient and user friendly too.

There are four types of control instructions in c program

(a)-Sequence Control Insruction-It insures that the instructions are executed in same order in which they appear in program

(b)- Decision Control Instruction- It allow the computer to take a decision as to which instruction is to be executed next

(c)-Loop Control Instruction-This instruction help computer to execute the group of statement repeatly.

(d)-Case Control Instruction– It allow the computer to take a decision as to which instruction is to be executed next

Decision Control Instruction

Using decision control statement, we can perform different actions based on the circumstances.

Decision control instructions:
1) The if statement
2) The if-else statement
3) The conditional operators
4) The switch statement

1. 