2 solutions

  • 1
    @ 2024-11-1 18:01:35

    #include <bits/stdc++.h> using namespace std; int main() { int a,b;char c; cin >> a >> b >> c; if(c == '+') { cout << a + b; } if(c == '-') { cout << a - b; } if(c == '*') { cout << a * b; } if(c == '/') { if(b == 0) { cout << "Divided by zero!"; } else { cout << a / b; } } if(c != '+' && c != '-' && c != '*' && c != '/') { cout << "Invalid operator!"; } return 0; }

    Information

    ID
    675
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    7
    Tags
    (None)
    # Submissions
    129
    Accepted
    32
    Uploaded By