Simply follow this tutorial
http://www.osix.net/modules/article/?id=53
#include<stdio.h>
main()
{
int n1,n2;
int sum,diff,mul,div;
printf("Calculator Menu");
printf("1. Addition");
printf("2. Subtraction");
printf("3. Multiplication");
printf("4. Division");
printf("Please choose from the following:[1,2,3,4] ");
scanf("%d",&choice");
if (choice==1)
{
printf("SUM: %d",sum);
}
else
if (choice==2)
{
printf("DIFFERENCE: %d",diff);
}
else
if (choice==3)
{
printf("PRODUCT: %d",mul);
}
else
if (choice==4)
{
printf("DIVIDEND: %d",div);
}
printf("Enter 1st number: ");
scanf("%d",&n1);
printf("Enter 2nd number: ");
scanf("%d",&n2);
sum=n1+n2;
diff=n1-n2;
mul=n1*n2;
div=n1/n2;
}
434 views
Usually answered in minutes!
Give my code a try. Post here if you got any errors. Hope it helps.
×