CMSC 140- FINAL EXAM 2025/2026
QUESTIONS AND ANSWERS 100% PASS
QUESTION 1:
The last legal subscript that can be used with the array intlist declared below (see array
declaration below) is [×1)
Avray declaration: intlist [10] - ANS 9
QUESTION 2:
Indicate If the following condition is True or False
Assume the variables x=5 y=6 and z=8
7 <=(x+y) && z > 4 - ANS True
QUESTION 3:
Choose the best answer to fill in the blank in the statement below.
A (An) BLANK function is a function that doesn't return a value. - ANS Void
QUESTION 4:
Indicate if the following expression is True or False
1 @COPYRIGHT 2025/2026 ALLRIGHTS RESERVED
, Assume the variables int a=3, b=4, c=6,
4!=b || c! = (a+3) - ANS True
QUESTION 5
Using a looping structure, prompt uner for positive integer values from the keyboard. Ignore all
negative values and terminate the loop once a value that is greater than 10 is entered. After the
loop ends , print the total of the read integers
Enter an integer 4
Enter an integer 8
Enter an integer 0
[Console] invalid please try again
Enter an integer 10
Enter an integer: 11
Total: 22 - ANS #include <iostream>
using namespace std;
int main() {
int total = 0, num;
while (true) {
cout << "Enter an integer: ";
cin >> num;
if (num < 0)
cout << "Invalid input. Please try again." << endl;
else if (num > 10)
break;
2 @COPYRIGHT 2025/2026 ALLRIGHTS RESERVED
QUESTIONS AND ANSWERS 100% PASS
QUESTION 1:
The last legal subscript that can be used with the array intlist declared below (see array
declaration below) is [×1)
Avray declaration: intlist [10] - ANS 9
QUESTION 2:
Indicate If the following condition is True or False
Assume the variables x=5 y=6 and z=8
7 <=(x+y) && z > 4 - ANS True
QUESTION 3:
Choose the best answer to fill in the blank in the statement below.
A (An) BLANK function is a function that doesn't return a value. - ANS Void
QUESTION 4:
Indicate if the following expression is True or False
1 @COPYRIGHT 2025/2026 ALLRIGHTS RESERVED
, Assume the variables int a=3, b=4, c=6,
4!=b || c! = (a+3) - ANS True
QUESTION 5
Using a looping structure, prompt uner for positive integer values from the keyboard. Ignore all
negative values and terminate the loop once a value that is greater than 10 is entered. After the
loop ends , print the total of the read integers
Enter an integer 4
Enter an integer 8
Enter an integer 0
[Console] invalid please try again
Enter an integer 10
Enter an integer: 11
Total: 22 - ANS #include <iostream>
using namespace std;
int main() {
int total = 0, num;
while (true) {
cout << "Enter an integer: ";
cin >> num;
if (num < 0)
cout << "Invalid input. Please try again." << endl;
else if (num > 10)
break;
2 @COPYRIGHT 2025/2026 ALLRIGHTS RESERVED