C++ – If Statement

if (x == 100)
  cout << "x is 100";
...
if (x == 100) { cout << "x is "; cout << x; }
...
if (x == 100)
  cout << "x is 100";
else
  cout << "x is not 100";
...
if (x > 0)
  cout << "x is positive";
else if (x < 0)
  cout << "x is negative";
else
  cout << "x is 0";
...

Working sample:


#include <iostream>
using namespace std;

int main ()
{
int x = 3;

if (x > 0)
  cout << "x is positive";
else if (x < 0)
  cout << "x is negative";
else
  cout << "x is 0";
return 0;
}