sluchaynayakotya

Untitled

Nov 30th, 2020
693
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.  
RAW Paste Data