Advertisement
rafikamal

Calculator

Jan 3rd, 2013
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.51 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.     float num1,num2;
  6.     int choice;
  7.  
  8.     printf("Enter 1st Number: ");
  9.     scanf("%f",&num1);
  10.  
  11.      printf("Enter 2nd Number: ");
  12.     scanf("%f",&num2);
  13.  
  14.     printf("1.sum 2.difference 3.product 4.subtraction\n");
  15.     printf("Please select: ");
  16.     scanf("%d",&choice);
  17.  
  18.     if(choice==1) printf("%f",num1+num2);
  19.     else if(choice==2) printf("%f",num1-num2);
  20.     else if(choice==3) printf("%f",num1*num2);
  21.     else if(choice==4) printf("%f",num1/num2);
  22.  
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement