Contact Learn C
Copy

Program 319:All Mathematical Operations using Macro Substitution

Program 319:All Mathematical Operations using Macro Substitution
 
#include <stdio.h>
#define Add +
#define Subtract -
#define Multiply *
#define Divide /
int main()
{
 int a,b,add,sub,mul;
 float div;
 printf("Enter a, b for all operations\n");
 scanf("%d%d",&a,&b);
 add=a Add b;
 printf("Addition of %d+%d=%d\n",a,b,add);
 sub=a Subtract b;
 printf("Subtraction of %d-%d=%d\n",a,b,sub);
 mul=a Multiply b;
 printf("Multiply of %dx%d=%d\n",a,b,mul);
 if(b>0)
 {
  div=((float)a/b);
  printf("Division of %d/%d=%f\n",a,b,div);
 }
 else
 {
  printf("Division is Not Possible\n");
 }
 
 return(0);
}
Explanation:

//Coming Soon...

Output:

All Mathematical Operations using Macro Substitution



Donate

Download App and Learn when ever you want

Get it on PlayStore
Get it on Amazon App Store
Get it on Aptoide