Skip to main content

C Programming for Beginner #3 (Instructions)


Types of Instruction


  1. Type Declaration: It is used to declare type of variables used in C Program.
  2. Arithmetic: It is used to perform Arithmetic operation on constant or variable.
  3. 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
  • Explanation:

  1. int a means we are a can store an integer values in a like 1,2,3,4 etc.
  2. float b means we can store a decimal values in b like 1.5 ,2.6 etc.
  3. char is used to declare character in C Program.
  • Arithmetic:
  1. c=a+b (Addition)
  2. c=a/b (Division)
  3. c=a*b (Multiplication)
  4. c=a%b (Modulus) these gives us the remainder after division.
  • Control:

  1. 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