We can easy perform the arithmetic operation without using third variable as the following
#include<stdio.h>
void main()
{
int a,b;
float div;
clrscr();
void main()
{
int a,b;
float div;
clrscr();
printf("enter the value of a=");
scanf("%d",&a);
printf("enter the value of b=");
scanf("%d",&b);
printf("\tsum=\t%d\n",a+b);//Addition Operation
printf("\tsub=\t%d\n",a-b); // Subtraction Operation
printf("\tmul=\t%d\n",a*b); //Multiplication Operation
printf("\tdiv=\t%f\n",a/b); //Division Operation
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