Part I – Write individual for( ) statements for the following cases:
1. Use a counter named p that has an initial value of 3, a final value of 18, and an increment of 1.
2. Use a counter named count that has an initial value of 1, a final value of 20, and an increment of 5.
3. Use a counter named j that has an initial value of 30, a final value of 10, and a decrement of 5.
4. Use a counter named price that has an initial value of 5, a final value of 15, and an increment of .5.
5. Use a counter named jcount that has an initial value of 20, a final value of 1, and a decrement of 2.
PART II - What will be the output of the following segment of the program?
1.
Output
for( p=2; p<=10; p += 2)
cout
“p is now: ”
p
endl;
2.
int total =50; Output
for ( i = 1; i <= 10; i += 2)
cout
i
endl;
3.
int total =0; Output
while(total<10) {
cout
” Hello”
endl;
XXXXXXXXXXtotal++;
}
4. Write a Program that used a repetition structure to display all even numbers between 0 and 200.