Guest User

Basic Multi-Function Calculator

a guest
Jan 17th, 2013
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.89 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3.  
  4.  
  5. int main(void)
  6. {
  7.     double num1, num2;
  8.     double product=0;
  9.     double type;
  10.     double xit;
  11. restart:
  12.         printf("Please Input the first Number\n");
  13.     scanf("%lf", &num1);
  14.     printf("Please Input the Second Number\n");
  15.     scanf("%lf", &num2);
  16.     printf("Please enter\n 1:Addition         %.2f + %.2f \n 2:Subtraction      %.2f - %.2f \n 3:Multiplication   %.2f * %.2f \n 4:Division         %.2f / %.2f \n", num1, num2, num1, num2, num1, num2, num1, num2);
  17.     scanf("%lf", &type);
  18.     if (type == 1)
  19.         product = num1 + num2;
  20.     else if (type == 2)
  21.         product = num1 - num2;
  22.     else if (type == 3)
  23.         product = num1 * num2;
  24.     else if (type == 4)
  25.         product = num1 / num2;
  26.     printf("The Solution is %.2f\n", product);
  27.     printf("To Exit press 1 or press 2 to restart\n");
  28.     scanf("%lf", &xit);
  29.  
  30.     if (xit == 1)
  31.         goto end;
  32.     else if (xit == 2)
  33.         system("cls");
  34.         goto restart;
  35. end:
  36.     return(0);
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment