1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
ipn [44]
3 years ago
12

Given the string variables name1 and name2, write a fragment of code that assigns the larger of the two to the variable first (a

ssume that all three are already declared and that name1 and name2 have been assigned values).
Computers and Technology
1 answer:
ArbitrLikvidat [17]3 years ago
3 0
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!

You might be interested in
2.3 Code Practice: Question 3
Tpy6a [65]

Answer:

Code in C++

Explanation:

C++ Code

#include<iostream> //for input and output  

using namespace std;  

int main()  

{  

  int hour;

  int minute;

  cout<<"Enter the hour:";

  cin>> hour;

  cout<<"Enter the minute:";

  cin>>minute;

  minute = minute+15;

  if(minute>=60){

   hour++;

   minute=minute-60;

  }

  if(hour>=24){

   hour=0;

  }

  cout<<"Hours: "<<hour<<endl;

  cout<<"Minutes:"<<minute;

  return 0;  

}

Code Explanation

First we need to declare two int variables to hold hour and minute values input from user.

Check if by adding 15 minutes into minute entered by user is greater then or equal to 60 then increment into hour and subtract 60 from minute.

Another check is that if user enters more then 24 hour or by making increment into hour, the hour values i greater then or equal to 24 then we need to change the hour to 0.

Result

Case 1:

Enter the hour:8

Enter the minute:15

Hours: 8

Minutes:30

Case 2:

Enter the hour:9

Enter the minute:46

Hours: 10

Minutes:1

8 0
3 years ago
You are writing an email to a potentional employer about a job opportunity. What can you do to make sure the email reflects your
Lina20 [59]
You want to use proper etiquette and be polite, do not call them by their first name and always refer to them as Mr., or Mrs. Use an extended vocabulary and do not talk about yourself.  If you have proper grammar, depending on the job, that can be seen as intelligence. And always use an appropriate closing that is respectful. Such as, Sincerely, John Doe.
4 0
4 years ago
Read 2 more answers
How Charles Babbage Concept of<br>Computer has help the modern<br>Computer​
OLga [1]

English mathematician and inventor Charles Babbage is credited with having conceived the first automatic digital computer. During the mid-1830s Babbage developed plans for the Analytical Engine. Although it was never completed, the Analytical Engine would have had most of the basic elements of the present-day computer.

6 0
3 years ago
Which statement will you use to create a scanner object scan to read input from the keyboard
vlabodo [156]

Answer:

<em><u>To create a Scanner object, you use the new keyword. To create a Scanner object that gets input from the keyboard, specify System.in in the parentheses. To use one of the methods of a Scanner object, code the object name, a dot (period), the method name, and a set of parentheses.</u></em>

8 0
3 years ago
The best how can i get. Ethiopian bank enterance examination for natural science grade 12?
zubka84 [21]

do your own work ************************************************************************************************************************************************************

5 0
4 years ago
Other questions:
  • Students recently created a Gaming Club at their school. On Friday every week, students bring in their gaming consoles (Xbox, Pl
    7·2 answers
  • Most colleges require blank years of foriegn language for admission
    9·1 answer
  • Given a dataset where the dataset is not linearly-separable, and each of the fea- tures have continuous values, which of the fol
    7·1 answer
  • Selling R frog for 50 r-obux on r-oblox!!! dont answer if u not gonna buy it
    15·2 answers
  • Which of these statements regarding mobile games is true? A. They are typically played indoors. B. They have detailed environmen
    15·2 answers
  • Give one advantage of saving file in the same folder<br>​
    13·2 answers
  • This my question for programming class
    10·1 answer
  • Janice’s grandmother stayed at home and took care of her family while her grandfather worked. Today Janice lives on her own and
    15·2 answers
  • How do i make a comment on brainly?
    15·1 answer
  • At which layer of the osi model would a logical address be added during encapsulation?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!