COSC 1415 Practice Test #2 conditions, while loops, for loops
Using the variable declarations below, what will the following conditions evaluate to?
int Apple = 5, Pear = 8, Grape = -4;
1. (Apple > Grape) select true false
2. (Pear > Grape && Apple < Pear) select true false
3. (Grape != 3 || Pear != 8) select true false
4. (!(Apple >= Apple) && !(Grape == (Pear - 12))) select true false
5. (Pear = Grape) select true false
How many iterations will the following for loops execute?
6. for (int X=1; X<=3; X++) select 0 1 2 3 4 5
7. for (int X=5; X>=0; X--) select 0 1 4 5 6 8
8. for (int G=0; G<8; G++) select 0 1 4 6 7 8
9. for (int Yellow=1; Yellow<=20; Yellow=Yellow+2) select 0 1 5 9 10 15
10. for (int X=5; X>8; X++) select 0 1 2 3 4 5
11. What C++ statement will allow your program to show the calendar for 2008? cal cal 2008 system(cal) system("cal 2008") cout << calendar
What will the following assignment statements evaluate to assuming the variable declarations below? int J = 1, K = 0, L = -1, M = 4, N = 3;
Here's some more difficult problems to really test your skill:
16. What will this output? select 5 6 7 8
17. What will this code output? select 8 86 68 169
18. What will this code output? select yes no yesno128 <no output>
19. What will this code output? select 02 13 024 1234
20. What does this code output? select 02 01 024 0011
21. What will this output? select 12345678 1234567 0123456 01234567
22. What will this output? select J K JK
You got out of correct. Your Score: %