A shortcut to learn the computer programming

WAP TO PERFORM ARITHMETIC OPERATION
We are providing the simple way to perform the arithmetic operation in easy and simple manner.In this program ,we are  also using the type conversion.

#include<stdio.h>
void main()
{
int a,b,sum,sub,mul;
float div;
clrscr();
printf("enter the value of a=");
scanf("%d",&a);
printf("enter the value of b=");
scanf("%d",&b);
sum=a+b;
printf("\tsum=\t%d\n",sum);
sub=a-b;
printf("\tsub=\t%d\n",sub);
mul=a*b;
printf("\tmul=\t%d\n",mul);
div=(float)a/b; //Type conversion
printf("\tdiv=\t%f\n",div);

getch();
}
O/P:-enter the value of a=6
     enter the value of b=2
     sum=8    sub=4     mul=12   div=3.0

No comments:

Post a Comment