Types of Instruction
- Type Declaration: It is used to declare type of variables used in C Program.
- Arithmetic: It is used to perform Arithmetic operation on constant or variable.
- Control: It is used to control the sequence of execution.
With the help of these instruction we make our C Program.
- Type Declaration:-
Example:
int a
float b
char code
char code
- Explanation:
- int a means we are a can store an integer values in a like 1,2,3,4 etc.
- float b means we can store a decimal values in b like 1.5 ,2.6 etc.
- char is used to declare character in C Program.
- Arithmetic:
- c=a+b (Addition)
- c=a/b (Division)
- c=a*b (Multiplication)
- c=a%b (Modulus) these gives us the remainder after division.
- Control:
- This instruction comes in picture when we deal with the loops,case control sequence of program or decision making.
Example Program:
include<stdio.h>
int main()
{
int a=5,b=5;
c=a+b;
d=a-b;
e=a/b;
f=a*b;
g=a%b;
printf("Added no is %d\n",c);
printf("Subtracted no is %d\n",d);
printf("Divided no is %d\n",e);
printf("Multiplied no is %d\n",f);
printf("Modded no is %d\n",g);
return 0;
}
Here I have used %d in printf it is used to tell the program to print digit if we want result in decimal we will use %f as it is for float and %c for char.
Output of the program will be:
Added no is 10
Subtracted no is 0
Divided no is 1
Multiplied no is 25
Modded no is 0
Note: You can compile this program try new thing and if you have any questions you can ask in comment section.
Comments
Post a Comment