bilalCh213

C++ Basic Arithmetic

May 12th, 2020
730
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     //+ - * / %
  8.     cout << 3 * 3 << endl;
  9.  
  10.     cout << 10 / 3 << endl;
  11.     cout << 10 % 3 << endl;
  12.  
  13.     cout << 7 / 2 << endl;
  14.     cout << 7 % 2 << endl;
  15.  
  16.     //+= -= *= /= %=
  17.     int no = 5;
  18.  
  19.     no += 10;
  20.     no %= 2;
  21.  
  22.     //++var var++ --var var--
  23.     cout << no++ << endl;
  24.     cout << --no << endl;
  25.     cout << no-- << endl;
  26.     cout << no << endl;
  27.  
  28.     //precedence/DMAS
  29.     //use of round brackets
  30.     cout << 10 / 4 * 2 - 10 + 15 / 4 << endl;
  31.     cout << 10 / (((6 - 3) * 10) + ((20 - 10) % 4));
  32.  
  33.     //type casting
  34.     cout < 3/2.0 << endl;
  35.  
  36.     int no2 = 7;
  37.     cout << 5/(float)no2 << endl;
  38.  
  39.     int pause;
  40.     cin >> pause;
  41.    
  42.     return 0;
  43. }
Add Comment
Please, Sign In to add comment