Compile a C++ that, keeps asking the user for int values from100 and 200 (inclusive).
First 3 integers, which are between the intervals, will be named one, two and three, print out the largest.
You'll keep asking the user until the number of inputs, which are between two intervals, changes to 3. Assume that the user isn't entering equalnumbers.
Must exit an output similar to this:
user inputs possibly be 100, 32, 114, -94 and 197.
one will be 100
two will be 114 and three will be 197.
Largest is 197.
Code
#include <iostream>
using namespace std;
int main()
{
int n,c=0,one,two,three,largest;
while(c!=3)
{
cin>>n;
if(n>=100 && n<=200 && c == 0)
{
one = n;
c++;
}
else if(n>=100 && n<=200 && c == 1)
{
two = n;
c++;
}
else if(n>=100 && n<=200 && c == 2)
{
three = n;
c++;
}
}
largest = std::max(one , std::max(two,three));
cout<<"One is : "<<one<<" Two is :
"<<two<<" Three is : "<<three<<endl;
cout<<"Largest is : "<<largest;
return 0;
}
Get Answers For Free
Most questions answered within 1 hours.