ahmed0saber

One-line Calculator 2 in C++

Nov 7th, 2020
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.27 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     float n , m ;
  6.     char s ;
  7.     cin>>n >>s >>m;
  8.     cout<<" = ";
  9.     if(s=='+')
  10.     {
  11.         cout<<n+m;
  12.     }
  13.     else if(s=='-')
  14.     {
  15.         cout<<n-m;
  16.     }
  17.     else if(s=='*')
  18.     {
  19.         cout<<n*m;
  20.     }
  21.     else if(s=='/')
  22.     {
  23.         cout<<n/m;
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment