menu
QAmmunity.org
Login
Register
My account
Edit my Profile
Private messages
My favorites
Ask a Question
Questions
Unanswered
Tags
Categories
Ask a Question
Given the string variables name1 and name2, write a fragment of code that assigns the larger of the two to the variable first (assume that all three are already declared and that name1 and name2 have been
asked
Aug 4, 2018
106k
views
2
votes
Given the string variables name1 and name2, write a fragment of code that assigns the larger of the two to the variable first (assume that all three are already declared and that name1 and name2 have been assigned values).
Computers and Technology
high-school
Necevil
asked
by
Necevil
7.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
7
votes
To screw with your teacher:
first = (name1 > name2 ) ? name1 : name2;
That code is correct, but your teacher is probably looking for:
if( name1 > name2 )
first = name1;
else
first = name2;
I love the ternary operator!
Ankit Deshpande
answered
Aug 10, 2018
by
Ankit Deshpande
8.5k
points
ask related question
comment
share this
0 Comments
Please
log in
or
register
to add a comment.
← Prev Question
Next Question →
Related questions
asked
Jul 23, 2020
177k
views
Given the char * variables name1, name2, and name3, write a fragment of code that assigns the largest value to the variable max (assume all three have already been declared and have been assigned values).
FFinn
asked
Jul 23, 2020
by
FFinn
7.9k
points
Computers and Technology
high-school
1
answer
5
votes
177k
views
asked
Sep 8, 2019
226k
views
Given the variables name1 and name2, write a fragment of code that assigns the larger of their associated values to first.
SEK
asked
Sep 8, 2019
by
SEK
8.6k
points
Computers and Technology
college
1
answer
3
votes
226k
views
asked
Apr 8, 2020
203k
views
Python Given the variables name1 and name2, write a fragment of code that assigns the larger of their associated values to first. (NOTE: "larger" here means alphabetically larger, not "longer". Thus, "mouse"
Darren Clark
asked
Apr 8, 2020
by
Darren Clark
8.5k
points
Computers and Technology
high-school
1
answer
2
votes
203k
views
Ask a Question
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.
9.5m
questions
12.2m
answers
Other Questions
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
Please help me ! All you do is just put it it all in your own words ! Please this is for my reported card!i don't know how to put it in my own words because my English is not that good!
describe an advance in technology that makes life more enjoyable. what discoveries contribute to this technology?
Disadvantages of using animation in advertising? advantages and disadvantages of using animation for education? advantages and disadvantages of using animation in entertainment?
Twitter
WhatsApp
Facebook
Reddit
LinkedIn
Email
Link Copied!
Copy
Search QAmmunity.org