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
raketka [301]
3 years ago
13

Write c++ program to find maximum number for three variables using statement ?​

Computers and Technology
1 answer:
pantera1 [17]3 years ago
3 0

Answer:

#include<iostream>

using namespace std;

int main(){

int n1, n2, n3;

cout<<"Enter any three numbers: ";

cin>>n1>>n2>>n3;

if(n1>=n2 && n1>=n3){

cout<<n1<<" is the maximum";}

else if(n2>=n1 && n2>=n3){

cout<<n2<<" is the maximum";}

else{

cout<<n3<<" is the maximum";}

return 0;

}

Explanation:

The program is written in C++ and to write this program, I assumed the three variables are integers. You can change from integer to double or float, if you wish.

This line declares n1, n2 and n3 as integers

int n1, n2, n3;

This line prompts user for three numbers

cout<<"Enter any three numbers: ";

This line gets user input for the three numbers

cin>>n1>>n2>>n3;

This if condition checks if n1 is the maximum and prints n1 as the maximum, if true

<em>if(n1>=n2 && n1>=n3){</em>

<em>cout<<n1<<" is the maximum";}</em>

This else if condition checks if n2 is the maximum and prints n2 as the maximum, if true

<em>else if(n2>=n1 && n2>=n3){</em>

<em>cout<<n2<<" is the maximum";}</em>

If the above conditions are false, then n3 is the maximum and this condition prints n3 as the maximum

<em>else{</em>

<em>cout<<n3<<" is the maximum";}</em>

return 0;

You might be interested in
Randy earn $22 per hour. This is an example of
ra1l [238]

Answer:

I am confused what the question is asking, but I am guessing what $22 per hour means? He earns $22 for every hour he works or does something.

So this hourly wage?  

Wage is the answer you are looking for.

8 0
3 years ago
There is an increasing need for private security personnel because of declining resources for many government agencies and a sho
aivan3 [116]
<span>True
</span><span>There is an increasing need for private security personnel because of declining resources for many government agencies and a shortage of police officers in many communities due to lack of funding.

</span>
8 0
4 years ago
"Rights and duties are two sides of the same coin." Explain with examples​
telo118 [61]

Answer:

Find the explanation below.

Explanation:

Rights are privileges that citizens or members of a community are entitled to by law. Duties are the responsibilities required of them. These two work together and are dependent on each other. Performing our duties help to safeguard our rights.

For example, the law specifies the right to life for people. This is an entitlement that should be respected by the individual and others around him. It is therefore the duty of the individual and others to respect this right to life and never compromise it in any way.

The law allows the right to free speech. It is also our duty to be patriotic and this would prevent compromising the right to free speech by saying unpatriotic things that can cause political tensions.

3 0
3 years ago
For which programming task would you use a for loop?
kicyunya [14]

Answer:

A. Computing the average of a list of integers of unknown length

6 0
3 years ago
One of the most basic agricultural tools is the tractor, which is designed to break up the soil in order to prepare it for plant
melisa1 [442]
False because the tractor doesn’t break up the soil
4 0
3 years ago
Other questions:
  • printStars is a method that accepts a single int argument and returns no value. It prints as many stars as indicated by its argu
    9·1 answer
  • Given that the array monthSales of integers has already been declared and that its elements contain sales data for the 12 months
    6·1 answer
  • The continue statement _________.
    11·1 answer
  • What layout manager should you use so that every component occupies the same size in the container?
    5·1 answer
  • What is one difference between IDLE and Eclipse?
    7·2 answers
  • Which of the following are good backup methods you can use to protect important files and folders from loss in the case of a har
    15·2 answers
  • Bradley is working on a program that uses different classes in specific relationships. Help him remember what these relationship
    14·1 answer
  • Which device contains or manages shared resources in a network?
    14·2 answers
  • Match the protocols to their use. HTTP POP3 SMTP FTP You check email in your inbox. arrowRight You send an email to a friend. ar
    14·1 answer
  • How to give answer like this?????
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!