For the following pseudo-code, indicate how many 3
times the loop body will execute for the input values: 2
5 -3 4 6.
userNum = 3
3/30/2026, 5:30:11 PM 3/30/2026, 5:30:09 PM
while (userNum > 0) {
// Do something
cin>> userNum
}
Given the following pseudo-code, how many times 10
will the "inner loop body" execute?
int row
int col
for(row = 0; row < 2; row = row + 1) { (CSCI Midterm Review (2026 Edition)
for(col = 0; col < 5; col = col + 1) {
// Inner loop body }
}
, Given the following pseudo code, indicate j's value at 0
the end of iteration i = 2.
for (int i = 0; i < 5; ++i) {
int j = 0
3/30/2026,
j = j * i 5:30:11 PM 3/30/2026, 5:30:09 PM
}
Given code: What is the final grade? final grade is C
double gradePoints = 85;
char final_grade = 'F';
if(gradePoints > 90)
final_grade = 'A';
if(gradePoints > 80)
(CSCI Midterm Review (2026 Edition)
final_grade = 'B';
if(gradePoints > 70)
final_grade = 'C';
else if(gradePoints > 60)
final_grade = 'D';
, Consider the if-elseif-else structure below: Invalid entry
if (x < -10)
cout<< "Disagrees"
else if (x == 10)
3/30/2026, 5:30:11 PM
cout<<"Neutral" 3/30/2026, 5:30:09 PM
else if (x > 0)
cout<<"Agrees"
else
cout<<"Invalid entry"
(CSCI Midterm Review (2026 Edition)
, Find the output key is 1 key is 2
int key = 1;
switch(key){
case 1:
3/30/2026,
cout <<5:30:11
"key is 1 PM
"; 3/30/2026, 5:30:09 PM
case 2:
cout << "key is 2 "; break;
case 3:
cout << "key is 3 ";
case 4:
cout << "key is 4 ";
default:
cout << "key is default "; break;}
Out put given as: num1 + num2 is 21 PrintSum(0 , 21);
(CSCI Midterm Review (2026 Edition)
The possible function call will be
void PrintSum(int num1, int num2) {
cout << num1 << " + " << num2 << " is " << (num1 + num2);
}
times the loop body will execute for the input values: 2
5 -3 4 6.
userNum = 3
3/30/2026, 5:30:11 PM 3/30/2026, 5:30:09 PM
while (userNum > 0) {
// Do something
cin>> userNum
}
Given the following pseudo-code, how many times 10
will the "inner loop body" execute?
int row
int col
for(row = 0; row < 2; row = row + 1) { (CSCI Midterm Review (2026 Edition)
for(col = 0; col < 5; col = col + 1) {
// Inner loop body }
}
, Given the following pseudo code, indicate j's value at 0
the end of iteration i = 2.
for (int i = 0; i < 5; ++i) {
int j = 0
3/30/2026,
j = j * i 5:30:11 PM 3/30/2026, 5:30:09 PM
}
Given code: What is the final grade? final grade is C
double gradePoints = 85;
char final_grade = 'F';
if(gradePoints > 90)
final_grade = 'A';
if(gradePoints > 80)
(CSCI Midterm Review (2026 Edition)
final_grade = 'B';
if(gradePoints > 70)
final_grade = 'C';
else if(gradePoints > 60)
final_grade = 'D';
, Consider the if-elseif-else structure below: Invalid entry
if (x < -10)
cout<< "Disagrees"
else if (x == 10)
3/30/2026, 5:30:11 PM
cout<<"Neutral" 3/30/2026, 5:30:09 PM
else if (x > 0)
cout<<"Agrees"
else
cout<<"Invalid entry"
(CSCI Midterm Review (2026 Edition)
, Find the output key is 1 key is 2
int key = 1;
switch(key){
case 1:
3/30/2026,
cout <<5:30:11
"key is 1 PM
"; 3/30/2026, 5:30:09 PM
case 2:
cout << "key is 2 "; break;
case 3:
cout << "key is 3 ";
case 4:
cout << "key is 4 ";
default:
cout << "key is default "; break;}
Out put given as: num1 + num2 is 21 PrintSum(0 , 21);
(CSCI Midterm Review (2026 Edition)
The possible function call will be
void PrintSum(int num1, int num2) {
cout << num1 << " + " << num2 << " is " << (num1 + num2);
}