Advertisement
Bassel_11

Untitled

Mar 21st, 2023
510
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. /*
  2. solve the bug in the following code
  3. */
  4. #include <bits/stdc++.h>
  5. using namespace std;
  6. /*
  7.     this program check if res = num1+num2
  8.     or res = num1 - num2
  9.     and print the right operator
  10.    
  11.     1<= num1,num2 <=9
  12.     -8<=res<=18
  13. */
  14. int main()
  15. {
  16.  
  17.     /*
  18.       i was trying to write conditional opertator to make my code looks cool
  19.       but something is wrong could you find it
  20.    */
  21.  
  22.     int num1, num2, res;
  23.     cin >> num1 >> num2 >> res;
  24.     cout << (num1 + num2 == res ? "+" : "-");
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement