Advertisement
sluchaynayakotya

Untitled

Nov 30th, 2020
746
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <cstdio>
  2.  
  3. int main()
  4. {
  5.   printf("Enter first number: ");
  6.   int a;
  7.   scanf("%d",&a);
  8.  
  9.   printf("Enter second number: ");
  10.   int b;
  11.   scanf("%d",&b);
  12.  
  13.   printf ("Choose the action: '+' or '-' or '*' or '/' : ");
  14.   char g;
  15.   scanf(" %c",&g);
  16.  
  17.   double z;
  18.  
  19.   if (g == '+') z = a + b;
  20.   else if (g == '-') z = a - b;
  21.   else if (g == '*') z = a * b;
  22.   else if (g == '/') z = (double)a / b;
  23.   else {
  24.     printf("You choose incorect action.");
  25.     return 0;
  26.   }
  27.  
  28.   printf("Anser is: %f", z);
  29.   return 0;
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement