Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 4 out of 34 pages
Exam (elaborations)

PS 150 – Final Exam Study Guide | Questions from Test #1 with Correct Answers

Document preview thumbnail
Preview 4 out of 34 pages

This focused study guide includes key questions from CPS 150 Test #1, complete with verified answers to support preparation for the final exam. It covers foundational topics in computer science such as binary systems, variables, data types, input/output operations, and basic programming syntax. Perfect for reinforcing core concepts and reviewing early course material.

Content preview

CPS 150 Final Exam Study Questions
From Test #1 with correct answers
Start

About This Quiz

This quiz focuses on foundational C++ concepts, essential for the CPS 150 final exam. It covers keywords,
identifiers, data types, syntax for comments and output operations, assessing readiness and deepening
understanding of C++ programming.



CPS 150 Final Exam Study Questions From Test #1 - Quiz

Quiz Preview



1/50 Questions

Determine the final value of the int variable angle when 0 is input.cout << "Enter angle: " ; cin >> angle
;if (angle >= 5) angle = angle + 5 ;else if (angle > 2) angle = angle + 10 ;else if (angle <= 0) angle = angle
- 15 ;else angle = angle +100 ;

2.

Determine the final value of the int variable angle when 5 is input.cout << "Enter angle: " ; cin >> angle
;if (angle >= 5) angle = angle + 5 ;else if (angle > 2) angle = angle + 10 ;else if (angle <= 0) angle = angle
- 15 ;else angle = angle +100 ;

Explanation

The final value of the int variable angle will be 10. This is because the input value of 5 satisfies the
condition in the first if statement (angle >= 5), so the value of angle is increased by 5. Since none of the
other conditions are met, the value remains unchanged.

Rate this question:



3.

Determine the final value of the int variable angle when 1 is input.cout << "Enter angle: " ; cin >> angle
;if (angle >= 5) angle = angle + 5 ;else if (angle > 2) angle = angle + 10 ;else if (angle <= 0) angle = angle
- 15 ;else angle = angle +100 ;

Explanation

,The final value of the int variable angle is 101. This is because the input value of 1 satisfies the condition
of the last "else" statement, which adds 100 to the angle. Therefore, the value of angle is 1 + 100 = 101.

Rate this question:



4.

Determine the final value of the int variable angle when 15 is input.cout << "Enter angle: " ; cin >> angle
;if (angle >= 5) angle = angle + 5 ;else if (angle > 2) angle = angle + 10 ;else if (angle <= 0) angle = angle
- 15 ;else angle = angle +100 ;

5.

Determine the final value of the int variable angle when -5 is input.cout << "Enter angle: " ; cin >> angle
;if (angle >= 5) angle = angle + 5 ;else if (angle > 2) angle = angle + 10 ;else if (angle <= 0) angle = angle
- 15 ;else angle = angle +100 ;

Explanation

The value of the variable angle is -5. Since -5 is less than 0, the condition of the third else if statement is
true. Therefore, the value of angle will be -5 - 15 = -20.

Rate this question:



6.

Fill in the blank that will allow the program to display the numbers 2 to 20 in steps of two (i.e. 2,4,6, ...,
20) with one number per output line.int number = ____________ ;while (number <= 20) { cout <<
number << endl ; number = (number +2) ;} // end while

Explanation

The blank should be filled with "2" because the program starts with the number 2 and then increments
it by 2 in each iteration of the while loop. This allows the program to display the numbers 2 to 20 in
steps of two.

Rate this question:



7.

Fill in the blank that will allow the program to display the numbers 2 to 20 in steps of two (i.e. 2,4,6, ...,
20) with one number per output line.int number = 2 ;while (_______________) { cout << number <<
endl ; number = (number +2) ;} // end while

Explanation

The blank should be filled with "number

,Rate this question:



1

8.

Fill in the blank that will allow the program to display the numbers 2 to 20 in steps of two (i.e. 2,4,6, ...,
20) with one number per output line.int number = 2 ;while (number <= 20) { cout << _________<< endl
; number = (number +2) ;} // end while

Explanation

The blank should be filled with "number" because the variable "number" is being printed in each
iteration of the loop, and it is incremented by 2 in each iteration to display the numbers 2 to 20 in steps
of two.

Rate this question:



9.

Fill in the blank that will allow the program to display the numbers 2 to 20 in steps of two (i.e. 2,4,6, ...,
20) with one number per output line.int number = 2 ;while (number <= 20) { cout << number <<
________ ; number = (number +2) ;} // end while

Explanation

The correct answer is "endl" because using "endl" in the code will insert a new line after each number is
displayed, resulting in one number per output line.

Rate this question:



10.

Fill in the blank that will allow the program to display the numbers 2 to 20 in steps of two (i.e. 2,4,6, ...,
20) with one number per output line.int number = 2 ;while (number <= 20) { cout << number << endl ;
__________________ ;} // end while

Explanation

The correct answer is "number = number + 2" or "number = (number + 2)". These statements increment
the value of the variable "number" by 2 in each iteration of the while loop, allowing the program to
display the numbers 2 to 20 in steps of two.

Rate this question:



11.

, The following program is supposed to read 10 integer values using a loop, and find the sum total of
those numbers. Fill in the blank to complete the program.int main () { int k, number ; int sum = 0 ;
__________; while (k <= 10) { cout << "Enter a number: " ; cin >> number ; sum = sum +
number ; k = k + 1 ; } // end while cout << "Result = " << sum << endl ; return 0;} //end main

Explanation

The variable "k" is initialized with a value of 1. This is important because it determines the condition for
the while loop. The loop will continue as long as the value of "k" is less than or equal to 10. By setting "k"
to 1, the loop will execute 10 times, allowing the program to read 10 integer values and calculate their
sum.

Rate this question:



12.

The following program is supposed to read 10 integer values using a loop, and find the sum total of
those numbers. Fill in the blank to complete the program.int main () { int k, number ; int sum = 0 ;
k = 1 ; while (_________) { cout << "Enter a number: " ; cin >> number ; sum = sum +
number ; k = k + 1 ; } // end while cout << "Result = " << sum << endl ; return 0;} //end main

Explanation

The blank should be filled with "k

Rate this question:



13.

The following program is supposed to read 10 integer values using a loop, and find the sum total of
those numbers. Fill in the blank to complete the program.int main () { int k, number ; int sum = 0 ;
k = 1 ; while (k <= 10) { cout << "Enter a number: " ; ____________; sum = sum + number ;
k = k + 1 ; } // end while cout << "Result = " << sum << endl ; return 0;} //end main

Explanation

The blank should be filled with "cin >> number" because it is the statement that allows the user to input
a number into the "number" variable. This statement is inside the while loop, which means it will be
executed 10 times, allowing the user to input 10 integer values. The "number" variable is then added to
the "sum" variable to calculate the total sum of the numbers.

Rate this question:



14.

Document information

Uploaded on
May 23, 2025
Number of pages
34
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$9.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
TUTOROUINE
3.1
(10)
Sold
50
Followers
0
Items
1666
Last sold
2 days ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions