http://www.jindent.com |
|
Next: If-Else Statements |
if-else
statements).For statements |
for
statements which just contain of a single statement instead
of a whole block:
for (int i = 0; i < n; i++) cout << i; |
for (int i = 0; i < n; i++) { cout << i; } |
While statements |
while
statements which just contain of a single statement instead
of a whole block:
while (++i < n) cout << i; |
while (++i < n) { cout << i; } |
Do-while statements |
do-while
statements which just contain of a single statement instead
of a whole block:
do cout << i; while (++i < n) |
do { cout << i; } while (++i < n); |
If-else statements |
if-else
statements which just contain of a single statement instead
of a whole block:
if (i == 0) callMethodA(); if (i < n) cout << i; else System.out.println(n); |
if (i == 0) { callMethodA(); } if (i < n) { cout << i; } else { System.out.println(n); } |
Conditions |
int x = a < 100 ? 1 : 0; if (x == 0 || 1000 > a && a > 10) { cout << a; } |
int x = (a < 100) ? 1 : 0; if ((x == 0) || ((1000 > a) && (a > 10))) { cout << a; } |