LOOPS: What is the EXACT output of the following code? for ( int i = 0 ; i < 10 ; i += 2 ) { cout << i << endl; } for ( int count = 10 ; count >= 0 ; count-- ) { cout << count << ' '; } cout << endl; for ( int j = 20 ; j >= 0 ; j -= 3 ) { cout << j << ".."; } cout << endl; for ( int k = 1 ; k != 6 ; k += 2 ) { cout << k << ' '; } cout << endl; Write a for loop to count from 10 to 1000 by 10s. ANSWERS: 0 2 4 6 8 10 9 8 7 6 5 4 3 2 1 0 20..17..14..11..8..5..2.. 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 ... !!! // count from 10 to 1000 by 10s for ( int i = 10 ; i <= 1000 ; i += 10 ) { // ... loop body } A for loop is used to count when we know both endpoints (e.g. count from 1 to 10000) A while loop is used when we don't know how many times we'll iterate through the loop Write a program to ask the user how many grades they want to type in. Then loop that many times (using a for loop) and ask for each grade value. Calculate the average. Next, write the same program, but use a while loop and don't ask the user how many grades to enter. Keep looping until the user inputs -1 (which is a "sentinel value") Show the average grade (make sure you don't include -1 in the calculations...) WHAT IS THE OUTPUT OF THIS NESTED LOOP? for ( int j = 0 ; j <= 10 ; j += 5 ) { for ( int k = 10 ; k > 0 ; k -= 5 ) { cout << j << " and " << k << endl; } }