my code so far.....
Code:
#include <stdio.h>
#include <math.h>
int main(void)
{
int sum, first_Num, sec_Num, diff, product, quotient;
int choice;
do
{
printf("\nChoose what calculation to perform\n");
printf("\t1 - Addition\n");
printf("\t2 - Subtration\n");
printf("\t3 - Multiplication\n");
printf("\t4 - Division\n");
printf("\t5 - Square Root\n");
printf("\t6 - Exponents\n");
printf("\t7 - Absolute Value\n");
printf("\t8 - Area of Shapes\n");
printf("(Enter a zero to exit) \n");
printf("What is your choice? ");
scanf("%d", &choice);
switch (choice)
{
case 1:
{
printf("Enter first number: ");
scanf("%d", &first_Num);
printf("Enter second number: ");
scanf("%d", &sec_Num);
sum = first_Num + sec_Num;
printf("\nThe sum of %d and %d is %d\n\n", first_Num, sec_Num, sum);
break;
}
case 2:
{
printf("Enter first number: ");
scanf("%d", &first_Num);
printf("Enter second number: ");
scanf("%d", &sec_Num);
diff = first_Num - sec_Num;
printf("\nThe difference of %d and %d is %d\n\n", first_Num, sec_Num, diff);
break;
}
case 3:
{
printf("Enter first number: ");
scanf("%d", &first_Num);
printf("Enter second number: ");
scanf("%d", &sec_Num);
product = first_Num * sec_Num;
printf("\nThe product of %d and %d is %d\n\n", first_Num, sec_Num, product);
break;
}
case 4:
{
printf("Enter first number: ");
scanf("%d", &first_Num);
printf("Enter second number: ");
scanf("%d", &sec_Num);
quotient = first_Num / sec_Num;
printf("\nThe quotient of %d and %d is %d\n\n", first_Num, sec_Num, quotient);
break;
}
}
}
while (choice != 0);
return (0);
}
I tried using %f, %lf and declaring quotient as a double, it gives me a bad data return