fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int i=55;
  8.  
  9. if (i==2)
  10. cout << "i is equal to 2" << endl;
  11. else
  12. cout << "i is not equal to 2" << endl;
  13.  
  14. // the following won't work as expected!
  15.  
  16. if (i=2)
  17. cout << "i is equal to 2" << endl;
  18. else
  19. cout << "i is not equal to 2" << endl;
  20.  
  21. if (2<i<15)
  22. cout << "i is between 2 and 15" << endl;
  23. else
  24. cout << "i is not between 2 and 15" << endl;
  25.  
  26. return 0;
  27. }
Success #stdin #stdout 0.01s 2680KB
stdin
Standard input is empty
stdout
i is not equal to 2
i is equal to 2
i is between 2 and 15