In C language, there are three types of instructions...
- Type Declaration Instruction
- Arithmetic Instruction
- Control Instruction
Iinstructions in C language | My Cs Tutorial |
Type Declaration Instruction
Type Declaration Instruction is used to declare the type of variables in C program.Whatever variables we want to use in the program, it should be declared before using it.Type declaration instruction statement written at the beginning of the program(just after main()).
Example:-
int m;
float n;
char name;
Example:-
int m;
float n;
char name;
Important points about Type Declaration Instruction
a) We can initialize the variable at the time of its declaration as shown below.
Example:-
Example:-
int i=8;,j=15;
float a=2.5;b=2.59+1.8* 2.36;
b) Remember the order of variables while declaring them.The order sometimes important sometimes not.
Example:-
int i=15,j=25; is same as int j=25,i=15;
However,
float i=3.5,j=i+5.7; is alright, but
float j=i+5.7,i=3.5; is not valid.
It is because in this declaration we are trying to use variable a even before defining it.
c) Another point while declaring variables is
Below instruction will work
Example:-
int i,j,k,l;
i=j=k=20;
However, the following statement would not work.
int i=j=k=l=20 ;
Now again we are trying to use variables even before defining them.
These definitions should be written at the beginning of the main() body. We can not define variables elsewhere in the program. If you do so, this will result in error.
Example:-
int i=15,j=25; is same as int j=25,i=15;
However,
float i=3.5,j=i+5.7; is alright, but
float j=i+5.7,i=3.5; is not valid.
It is because in this declaration we are trying to use variable a even before defining it.
c) Another point while declaring variables is
Below instruction will work
Example:-
int i,j,k,l;
i=j=k=20;
However, the following statement would not work.
int i=j=k=l=20 ;
Now again we are trying to use variables even before defining them.
These definitions should be written at the beginning of the main() body. We can not define variables elsewhere in the program. If you do so, this will result in error.
Arithmetic Instruction
Arithmetic instructions are used to perform arithmetic operations on variables and constants. Here we will learn some new terms. These are operands and operators.
Example:-
prin = 4500;
amo = 55.45;
deta=hin*eng/math+5.4×5-3;
Here +,-,*,/ are the arithmetic operators and = is the assaiment operator.
5.4 and 55.45 are real constants.
5,3 and 4500 are integer constants.
prin is an integer variable.
amo is real variable.
- It should contain one assaiment operator i.e. =.
- AC arithmetic instruction consists of variable name on left hand side of = operator and variable names and constants on right hand side of = operator.
- The variable and constants are appearing on the right hand side of = are connected by arithmetic operators like +, -, * , /.
Example:-
prin = 4500;
amo = 55.45;
deta=hin*eng/math+5.4×5-3;
Here +,-,*,/ are the arithmetic operators and = is the assaiment operator.
5.4 and 55.45 are real constants.
5,3 and 4500 are integer constants.
prin is an integer variable.
amo is real variable.
Types Of Arithmetic Instruction
There are three types of arithmetic instruction.- Integer mode arithmetic statement
- Real mode arithmetic statement
- Mixed mode arithmetic statement
Integer mode arithmetic statement
In this statement all operands are either integer constant or integer variable.
Example:-
int i,squ;
i=I+1;
squ=I*I;
Real mode arithmetic statement
In this statement all operands are either real constant or real variable.
Example:-
float rate,si prin,anoy;
si=prin*anoy*rate/100;
Mixed mode arithmetic statement
In this statement some operands are integer and some some operands are real.
Example:-
float si,prin,anoy,rate,avg;
into I,j,k,num;
si=prin*anoy*rate/100;
avg=(i+j+k+num)/4;
Operands
Combination of variables and constants are called operands. These operands are connected by arithmetic operators.
Operands
Combination of variables and constants are called operands. These operands are connected by arithmetic operators.
Control instruction
Control instruction is used to control the flow of the program.We know program is a set of instructions.The processor execute the instructions in that sequence in which we write the program by instructions.The control of the processor runs from one line to another, we can say that this sequence of processor control runs in sequence.
There are some types of control instruction in C which are as..
- Sequence control instruction
- Decision control instruction
- Loop control instruction
- Switch case control instruction
No comments:
Post a Comment