Question

Write a C++ program that does the following: Asks the user to enter 3 integers, Obtains...

Write a C++ program that does the following: Asks the user to enter 3 integers, Obtains the numbers from the user, Prints the largest number and then the smallest of the numbers, If the numbers are equal, prints the message: "These numbers are equal." Prints the sum, average, and product of the 3 numbers.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

C++ code

=================================================================

#include <iostream>

using namespace std;
int main() {

int a,b,c;
int large,small;
cout<<"Enter first interger: ";
cin>>a;
cout<<"Enter second interger: ";
cin>>b;
cout<<"Enter third interger: ";
cin>>c;

//find greatest and smallest number

large = a > b ? (a > c ? a : c) : (b > c ? b : c);

small = a < b ? (a < c ? a : c) : (b < c ? b : c);

if(a==b && a==c && b==c)
cout<<"These numbers are equal."<<endl;
else
{

cout<<large<<" is the largest number"<<endl;
cout<<small<<" is the smallest number"<<endl;
}


cout<<"sum of 3 numbers: "<<(a+b+c)<<endl;
cout<<"product of 3 numbers: "<<(a*b*c)<<endl;
cout<<"average of 3 numbers: "<<(a+b+c)/3.0<<endl;
return 0;
}

=================================================================

Output

Add a comment
Know the answer?
Add Answer to:
Write a C++ program that does the following: Asks the user to enter 3 integers, Obtains...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. Write a program that asks the user to enter two integers, obtains the numbers from...

    1. Write a program that asks the user to enter two integers, obtains the numbers from the user, then prints the larger number followed by the words “is larger.” If the numbers are equal, print the message “These numbers are equal.” Use only the single-selection form of the if statement you learned in this chapter.

  • Write a java program that asks the user to enter 2 integers, obtains them from the...

    Write a java program that asks the user to enter 2 integers, obtains them from the user, determines if they are even or odd numbers and prints their sum, product, difference, and quotient (Division).

  • Write an application that asks the user to enter two integers, obtains them from the user...

    Write an application that asks the user to enter two integers, obtains them from the user and prints their sum, product, difference and quotient (division).(i.e. Scanner, nextInt and printf) (this has to be in java) Enter·first·integer:31 ·Enter·second·integer:69 ·31+69=100 31*69=2139 31-69=-38 31/69=0

  • C++ Write a program that prompts the user to enter integers or a sentinel to stop....

    C++ Write a program that prompts the user to enter integers or a sentinel to stop. The program prints the highest and lowest numbers entered, the sum and the average. DO NOT USE ARRAYS, only variables and loops. Write a program the prompts the user to input a positive integer. Keep asking the user until a positive integer is entered. Once a positive integer is entered, print a message if the integer is prime or not. (NOTE: A number is...

  • Write a program that asks the user how many integers they would like to enter. You...

    Write a program that asks the user how many integers they would like to enter. You can assume they will enter an integer >= 1. The program will then prompt the user to enter that many integers. After all the numbers have been entered, the program should display the largest and smallest of those numbers (no, you cannot use lists, or any other material we haven't covered). When you run your program it should match the following format: How many...

  • Write a complete C++ program to ask the user to enter 4 integers. The program must...

    Write a complete C++ program to ask the user to enter 4 integers. The program must use a function to find the smallest integer among them and print it on the screen. Typical output screen should be as following: Write a complete C++ program to ask the user to enter 4 integers. The program must use a functionto find the smallest integer among them and print it on the screen. Typical output screen should be as following: Note: the code...

  • Write a program that lets the user enter 10 values into an array. The program should...

    Write a program that lets the user enter 10 values into an array. The program should then display the largest and the smallest values stored in the array. The program should display the following message to the user at the beginning "This program will ask you to enter ten values. Then it will determine the largest and smallest of the values you entered.Please enter 10 integers separated by spaces: " And then after user entered the numbers, it should display...

  • In C++ 2. Write a program that allows the user to enter a series of positive...

    In C++ 2. Write a program that allows the user to enter a series of positive numbers between 1 and 100 and displays the smallest and largest of the numbers entered. The program should not store the numbers that were entered, only keep track of the smallest and largest ones. The program should continue accepting numbers until the value 0 is entered and then display the results. If a number out of range is entered, tell the user it is...

  • Write a C++ program that asks the user to enter a single number from 1 to...

    Write a C++ program that asks the user to enter a single number from 1 to 50 and a choice of "even" or "odd". Using a recursive function, output the sum of all the even or odd integers from 1 up to (and including) that number. Your program does not need to loop and accept more input (only one input of the number then even/odd).

  • Using loops, write a C# program that asks the user to enter repeatedly an integer number,...

    Using loops, write a C# program that asks the user to enter repeatedly an integer number, it stops when the user enters -1, then the program should display how many numbers were entered, their the sum and their average

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT