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 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...

  • 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).

  • Write a program that asks the user to enter 1000 integers to be stored in an...

    Write a program that asks the user to enter 1000 integers to be stored in an array called "numbers". Since the same integer might occur (exist) in the array multiple times, your program needs to fill a second array, called "Isolate" that contains all the integers from the first array but NOT REPAPTED (every integer will exist only once). Finally, your program will print the integers of the second array sorted by occurrence (occurrence is: the number of times the...

  • Write a Java program that: • Asks the user to enter the number of integers that...

    Write a Java program that: • Asks the user to enter the number of integers that he need to enter; • Asked him to enter integer by integer; • Print The number of Odd numbers entered and the number of Even numbers entered. Important notes: 1. You should have to copy and paste the Java as your answer for this question. DON’T take screen shot for your Java Code. It must be editable. 2. Take a screen shot for your...

  • Write a program that prompts the user to input three different integers from the keyboard, then...

    Write a program that prompts the user to input three different integers from the keyboard, then prints the sum, the average, and the product. The screen dialogue should appear exactly as follows: Enter three different integers: 13 27 14 Sum is 54 Average is 18 Product is 4914 Please code in c program

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