menu
Qammunity.org
Login
Register
My account
Edit my Profile
Private messages
My favorites
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 <…
Ask a Question
Questions
Unanswered
Tags
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 <…
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 & Tech
high-school
Colby Africa
asked
by
Colby Africa
8.4k
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
8.3k
points
ask related question
comment
share this
0 Comments
Please
log in
or
register
to add a comment.
a. Error b. My name is BobBob c. My name is BobMy name is Bob d. My name is Bob Bob" CLASS="qa-prev-q theme">← Prev Question
Next Question →
Related questions
asked
Oct 28, 2024
86.9k
views
What will the following code display? int x = 0, y = 1, z = 2; cout << x << y << z << endl; A) 0 1 2 B) 0 1 2 C) xyz D) 012
Zayda
asked
Oct 28, 2024
by
Zayda
8.4k
points
Computers & Tech
high-school
1
answer
5
votes
86.9k
views
asked
Jan 14, 2024
141k
views
What would be the output of the following code? #include < using namespace std; int main() { int x = 30; if(x > 20) if (x < 30) cout << x*2 << endl; else cout << x*3 << endl; cin.ignore(); return 0; }
ASP
asked
Jan 14, 2024
by
ASP
7.5k
points
Computers & Tech
college
1
answer
0
votes
141k
views
asked
Jun 6, 2024
16.8k
views
How many times will the following loop execute? int x = 0; do { x++; cout << x << endl; }while(x < 5) Answers: a. - 5 times b. - 4 times c. - It doesn't d. - Infinite times e. - 6 times
Tim Dams
asked
Jun 6, 2024
by
Tim Dams
7.5k
points
Mathematics
high-school
1
answer
4
votes
16.8k
views
Ask a Question
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.
9.4m
questions
12.2m
answers
Categories
All categories
Mathematics
(3.7m)
History
(955k)
English
(903k)
Biology
(716k)
Chemistry
(440k)
Physics
(405k)
Social Studies
(564k)
Advanced Placement
(27.5k)
SAT
(19.1k)
Geography
(146k)
Health
(283k)
Arts
(107k)
Business
(468k)
Computers & Tech
(195k)
French
(33.9k)
German
(4.9k)
Spanish
(174k)
Medicine
(125k)
Law
(53.4k)
Engineering
(74.2k)
Other Questions
“What does it mean when we “rework” copyrighted material?”
The book shows how to add and subtract binary and decimal numbers. However, other numbering systems are also very popular when dealing with computers. The octal (base 8) numbering system is one of these.
Seven basic internal components found in a computer tower
Twitter
WhatsApp
Facebook
Reddit
LinkedIn
Email
Link Copied!
Copy
Search Qammunity.org