#include double a=0,s=0,m=0,d=0; int g=0; /* Function declarations */ double add(double a, double b); /* Function definitions */ double add(double a, double b) { double a1=a+b; return a1; } double subtract(double a,double b) { double s = a-b; return s; } double multiply(double a, double b) { double m = a*b; return m; } double divide(double a,double b) { double d = a/b; return d; } int gcd(int a,int b) { int t=0; while(b!=0) { t = b; b = a%b; a = t; } g = a; return g; } int main(void) { double a=0,s=0,m=0,d=0,x=0,y=0; int g =0; int option; while(1) { printf("******* Calculator ********\n"); printf("1: Add 2 numbers\n"); printf("2: Subtract 2 numbers\n"); printf("3: Multiply 2 numbers\n"); printf("4: Divide 2 numbers\n"); printf("5: GCD of 2 numbers\n"); printf("6: Quit\n"); printf("Enter choice from 1-5, 6 to quit: "); scanf("%d",&option); if(option<6) { printf("Enter first number: "); scanf("%lf",&x); printf("Enter second number: "); scanf("%lf",&y); } switch (option) { case 1: a = add(x,y); printf("Sum = %f\n",a); break; case 2: s = subtract(x,y); printf("Difference = %f\n",s); break; case 3: m = multiply(x,y); printf("Product = %f\n",m); break; case 4: d = divide(x,y); printf("Ratio = %f\n",d); break; case 5: g = gcd((int)x,(int)y); printf("GCD = %d\n",g); break; case 6: printf("Quitting!!!!!\n"); break; } if(option == 6) {break;} } return 0; }