Question: in this program can you change it to use looping and allow it to use more then 3 integers. using C++ #include using namespace std;
in this program can you change it to use looping and allow it to use more then 3 integers. using C++
#include
using namespace std;
int main()
{
int num1, num2, num3, smallest, largest;
cout << "Input three different integers: ";
cin >> num1 >> num2 >> num3; // input
largest = num1;
if ( num2 > largest )
largest = num2;
if ( num3 > largest )
largest = num3;
smallest = num1;
if ( num2 < smallest )
smallest = num2;
if ( num3 < smallest )
smallest = num3;
cout << "Sum is " << num1 + num2 + num3
<< " Average is " << (num1 + num2 + num3) / 3
<< " Product is " << num1 * num2 * num3
<< " Smallest is " << smallest
<< " Largest is " << largest << endl;
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
