Write a program in C to add, substract, multiply & divide two numbers
Method - I (using 5 variables)
Method - II (using 3 variables)
Method - I (using 5 variables)
#include <stdio.h>
void main ()
{
int a,b,c,d,e,f;
clrscr();
printf ("Enter A: ");
scanf ("%d",&a);
printf ("Enter B: ");
scanf ("%d",&b);
c=a+b;
d=a-b;
e=a*b;
f=a/b;
printf ("\nSum is : %d",c);
printf ("\nSubtraction is : %d",d);
printf ("\nMultiplication is : %d",e);
printf ("\nDivision is : %d",f);
getch ();
}
Method - II (using 3 variables)
#include <stdio.h>
void main ()
{
int a,b,c;
clrscr();
printf ("Enter A: ");
scanf ("%d",&a);
printf ("Enter B: ");
scanf ("%d",&b);
c=a+b;
printf ("\nSum is %d",c);
c=a-b;
printf ("\nSubtraction is %d",c);
c=a*b;
printf ("\nMultiplication is %d",c);
c=a/b;
printf ("\nDivision is %d",c);
getch ();
}
Post a Comment