Hello everyone,
I need to input 3 numbers and find the greatest/lowest number using if statements.
So far I have:
#include <iostream>
int main()
{
int n1;
int n2;
int n3;
int lowest;
int greatest;
greatest = n1;
if ( n2 >= greatest )
{
n2 = greatest;
}
if ( n3 >= greatest )
{
n3 = greatest;
}
lowest = n1;
if ( n2 <= lowest )
{
n2 = lowest;
}
if ( n3 <= lowest )
{
n3 = lowest;
}
std::cout << "Greatest=" << greatest << std::endl;
std::cout << "Lowest=" << lowest << std::endl;
return 0;
}
I specifically have to use if statements.
Any thoughts?
Thanks
Last edited on
Thanks, figured it out... my n2 > lowest statements were reversed...
Right to left, not left to right...