Test I. CONCEPTS (34 pts)
A. Enumeration (3 pts
each, a total of 9)
Syntax/ General Format of
while, for and do-while loop structure, in order.
1.
2.
3.
B. Program Tracing (5 pts each, a total of 25)
Determine the output of the following code snippet through
program tracing.
1.
for (int var1=1; var1<=10; var1++){
var1 = var1 + 6;
cout << var1;
}
2.
int x=1;
do{
if ( x ==4)
x=9;
cout << x;
}while (x
<= 5);
3.
for (int j=1; j >= 10; j++){
cout
<< j;
}cout
<< j;
4.
int i=1;
while( i
<= 10){
cout << i;
}
5.
for (int i=1; i<=10; i+=5){
cout
<< i;
i=i+5;
}
Test II. CODE WRITING (25 pts)
Problem:
Write
a program to require an integer input between 1 and 10. Vary and display the
control variable of a for-loop statement starting from 1 to 10 and put a dollar
($) sign in place of that number.
Sample output #1:
Enter an integer value between 1 and
10: 6
12345$78910
Sample output #2:
Enter an integer value between 1 and
10: 10
123456789$
Sample output #3:
Enter an integer value between 1 and
10: 3
No comments:
Post a Comment