menu
QAmmunity.org
Login
Register
My account
Edit my Profile
Private messages
My favorites
Register
Ask a Question
Questions
Unanswered
Tags
Categories
Ask a Question
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; a. 2 b. 3 c. 4 d. 1
asked
Apr 17, 2020
176k
views
1
vote
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;
a. 2
b. 3
c. 4
d. 1
Computers and Technology
high-school
Colby Africa
asked
by
Colby Africa
5.5k
points
answer
comment
share this
share
0 Comments
Please
log in
or
register
to add a comment.
Please
log in
or
register
to answer this question.
1
Answer
3
votes
Answer:
The answer is
"Option b".
Explanation:
In the C++ language program code, there are four integer type variable is defined that is "x, y,z, and result" in which variable x,y,z holds a value that is "1" and the variable result does not hold any value.
In the next line, variable y holds added value of variable y and z, which is equal to 2. and variable x holds added value of variable x and y, which is equal to 3.
In the next line, a Ternary Operator is defined, it is similar to an if-else statement. This operator checks if x variable value is less then y. If this condition is true, it will print y variable value Otherwise, it will print x variable value. That's why the out to this question is "
option b
".
Adriano Campos
answered
Apr 21, 2020
by
Adriano Campos
5.7k
points
ask related question
comment
share this
0 Comments
Please
log in
or
register
to add a comment.
Ask a Question
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.
5.9m
questions
7.7m
answers
Other Questions
A new information system is not considered in production until conversion is complete
a. STOP: What is a technology habit you practice today that you now realize will not help you to be successful? Explain why it’s important to STOP doing this right now.
Why might the government censor what its citizens see on the internet?
Flash drives cds external disks are all examples of storage (memory) devices
What is a spreadsheet program? A spreadsheet program is a computerized version of _________
Twitter
WhatsApp
Facebook
Reddit
LinkedIn
Email
Link Copied!
Copy
Search QAmmunity.org