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
Exam (elaborations)

PROGRAMMING Final Exam 2023 with complete solution

Rating
-
Sold
-
Pages
22
Grade
A
Uploaded on
12-06-2023
Written in
2022/2023

PROGRAMMING Final Exam 2023 with complete solution Input values should always be checked for: Appropriate range, reasonableness, and division by zero, if division is taking place. What is the value of the following expression? true && false false What will be the output of the following code segment after the user enters 0 at the keyboard? int x = -1; cout "Enter a 0 or a 1 from the keyboard: "; cin x; if (x) cout "true" endl; else cout "false" endl; false Relational operators allow you to ________ numbers. compare Given the following code segment, what is output after "result = "? int x = 1, y = 1, z = 1; y = y + z; x = x + y; cout "result = " (x y ? y : x) endl; 3 If you place a semicolon after the statement: if (x y) The compiler will interpret the semicolon as a null statement. What will the following program segment display? int funny = 7, serious = 15; funny = serious % 2; if (funny != 1) { funny = 0; serious = 0; }

Show more Read less
Institution
Course

Content preview

PROGRAMMING Final Exam 2023 with complete
solution
Input values should always be checked for:
Appropriate range, reasonableness, and division by zero, if division is taking place.
What is the value of the following expression?
true && false
false
What will be the output of the following code segment after the user enters 0 at
the keyboard?

int x = -1;
cout << "Enter a 0 or a 1 from the keyboard: ";
cin >> x;
if (x)
cout << "true" << endl;
else
cout << "false" << endl;
false
Relational operators allow you to ________ numbers.
compare
Given the following code segment, what is output after "result = "?

int x = 1, y = 1, z = 1;
y = y + z;
x = x + y;

cout << "result = "
<< (x < y ? y : x)
<< endl;
3
If you place a semicolon after the statement:

if (x < y)
The compiler will interpret the semicolon as a null statement.
What will the following program segment display?

int funny = 7, serious = 15;
funny = serious % 2;

if (funny != 1)
{
funny = 0;
serious = 0;
}

,else if (funny == 2)
{
funny = 10;
serious = 10;
}
else
{
funny = 1;
serious = 1;
}
cout << funny << " " << serious << endl;
11
What will the following segment of code output?
Assume the user enters a grade of 90 from the keyboard.

cout << "Enter a test score: ";
cin >> test_score;
if (test_score < 60);
cout << "You failed the test!" << endl;
if (test_score > 60)
cout << "You passed the test!" << endl;
else
cout << "You need to study for the next test!";
You failed the test!
You passed the test!
What will be the value of result after the following code has been executed?

int a = 60;
int b = 15;
int result = 10;

if (a = b)
result *= 2;
20
After execution of the following code, what will be the value of input_value if the
value 0 is entered at the keyboard at run time?

cin >> input_value;
if (input_value > 5)
input_value = input_value + 5;
else if (input_value > 2)
input_value = input_value + 10;
else
input_value = input_value + 15;
15
When a relational expression is false, it has the value ________.

, zero
What will the following segment of code output if the value 11 is entered at the
keyboard?

int number;
cin >> number;

if (number > 0)
cout << "C++";
else
cout << "Soccer";
cout << " is ";
cout << "fun" << endl;
C++ is fun
What is the value of the following expression?

true || true
true
This is a variable, usually a bool or an int, that signals when a condition exists.
flag
What is the output of the following segment of code if the value 4 is input by the
user when asked to enter a number?

int num;
int total = 0;
cout << "Enter a number from 1 to 10: ";
cin >> num;
switch (num)
{
case 1:
case 2: total = 5;
case 3: total = 10;
case 4: total = total + 3;
case 8: total = total + 6;
default: total = total + 4;
}
cout << total << endl;
13
There are_____bytes in a bit
a. 64
b. 8
c. 4
d. None of the above
d. none of the above
______is the code you write
source code

Written for

Course

Document information

Uploaded on
June 12, 2023
Number of pages
22
Written in
2022/2023
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$13.99
Get access to the full document:

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

Get to know the seller

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.
magdamwikash23 Western Governers University
Follow You need to be logged in order to follow users or courses
Sold
113
Member since
3 year
Number of followers
94
Documents
5328
Last sold
2 weeks ago
Magda

NURSING STUDY GUIDES/EXAMS AND NOTES ALL VERIFIED BY EXPERTS All my uploaded documents, exams and essays are verified by relevant experts.I can assure an A or at least 90% if you use any of my documents.

3.9

14 reviews

5
7
4
2
3
2
2
2
1
1

Trending documents

Recently viewed by you

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

Frequently asked questions