[6502acme] Nihad

Viewer

  1. #include <iostream>
  2.  
  3. int main() {
  4.     double num1, num2;
  5.     char operation;
  6.     double result;
  7.  
  8.     std::cout ​`oaicite:{"index":0,"invalid_reason":"Malformed citation << \"Enter the first number: \";\n    std::cin >>"}`​ num1;
  9.  
  10.     std::cout ​`oaicite:{"index":1,"invalid_reason":"Malformed citation << \"Enter the second number: \";\n    std::cin >>"}`​ num2;
  11.  
  12.     std::cout ​`oaicite:{"index":2,"invalid_reason":"Malformed citation << \"Enter the operation (+-*/): \";\n    std::cin >>"}`​ operation;
  13.  
  14.     switch (operation) {
  15.         case '+':
  16.             result = num1 + num2;
  17.             break;
  18.         case '-':
  19.             result = num1 - num2;
  20.             break;
  21.         case '*':
  22.             result = num1 * num2;
  23.             break;
  24.         case '/':
  25.             result = num1 / num2;
  26.             break;
  27.         default:
  28.             std::cout << "Invalid operation";
  29.             return 0;
  30.     }
  31.  
  32.     std::cout << "Result: " << result << std::endl;
  33.     return 0;
  34. }
  35.  

Editor

You can edit this paste and save as new:


File Description
  • Nihad
  • Paste Code
  • 27 Jan-2023
  • 1.03 Kb
You can Share it: