page 16: #include using namespace std ; int main() { int x = 2 ; if (x > 1) cout << "yes\n" ; cin.get() ; return 0 ; } page 16: #include using namespace std ; int main() { int x=2 ; if (x==2) cout << "yes\n" ; cin.get() ; return 0 ; } page 16: #include using namespace std ; int main() { int x=2 ; if (x==2) { cout << "yes\n" ; cout << "of course\n" ; } cin.get() ; return 0 ; } page 17: #include using namespace std ; int main() { int x=2 ; if (x==2) cout << "yes\n" ; else cout << "no\n" ; cin.get() ; return 0 ; } page 17: #include using namespace std ; int main() { int x = 2 ; if (x==2) if (x>1) cout << "yes\n" ; cin.get() ; return 0 ; } page 17: #include using namespace std ; int main() { int x = 2 ; if (x > 2) cout << "x>2\n" ; else if (x > 1 ) cout << "x>1\n" ; else if (x > 0) cout << "x>0\n" ; cin.get() ; return 0 ; } page 18: #include using namespace std ; int main() { int x = 5 ; switch (x) { case 4: cout << "no\n" ; break ; case 5: cout << "yes\n" ; break ; case 6: cout << "not\n" ; break ; } cin.get() ; return 0 ; } page 18: #include using namespace std; int main() { cout << (10<5) ; cout << endl; cout << (10==5) ; cout << endl; cout << (10>5) ; cout << endl; cout << (10!=5) ; cout << endl; return 0 ; } page 18: #include using namespace std ; int main() { bool b ; b = true ; cout << b << endl ; return 0 ; cin.get() ; } page 19: #include using namespace std ; int main() { int i ; for (i=0;i<4;i++) cout << i ; return 0 ; } for (i=0;i<4;i++) { cout << i << endl; cout << "looping" << endl; } #include using namespace std ; int main() { int i = 0 ; while (i < 4) { cout << i << endl ; i++ ;} cin.get() ; return 0 ; } #include using namespace std ; int main() { int i = 0 ; do { cout << i << endl ; i++ ;} while (i < 4) ; cin.get() ; return 0 ; } page 20: #include #include using namespace std ; int main() { char ch ; ch = getche() ; cin.get() ; return 0 ; } #include using namespace std ; int main() { int i = 1 ,j ; j = (i < 2) ? 3 : 4 ; cout << j << endl ; cin.get() ; return 0 ; } page 20: #include using namespace std ; int main() { int i = 2 ; if (i == 1 || i == 2) cout << "yes" << endl ; cin.get() ; return 0 ; } #include using namespace std ; int main() { int i = 1 , j = 2 ; if (i == 1 && j == 2) cout << "yes" << endl ; cin.get() ; return 0 ; } page 25: #include using namespace std ; int main() { int h ; h = 0xC ; cout << h << endl ; cout << hex << h << endl ; cin.get() ; return 0 ; }