# find the highest and lowest of 3 intergers

Page 1 of 1

## 4 Replies - 20801 Views - Last Post: 05 February 2007 - 10:12 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=23580&amp;s=3793ed9a60145e57f4a88e00649fb7c7&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 fire21

Reputation: 0
• Posts: 7
• Joined: 04-February 07

# find the highest and lowest of 3 intergers

Posted 05 February 2007 - 12:39 AM

..........
if (num1<=num2)
cin >> least;
cout << "Least Integer is: ";

if (num1<=num3)
cin >> least;
cout << "Least Integer is: ";

if (num2<=num3)
cin >> least;
cout << "Least Integer is: ";

if (num2<=num1)
cin >> least;
cout << "Least Integer is: ";

if (num3<=num1)
cin >> least;
cout << "Least Integer is: ";

if (num3<=num2)
cin >> least;
cout << "Least Integer is: ";

if (num1>=num2)
cin >> largest;
cout << "Largest Integer is: ";

if (num1>=num3)
cin >> largest;
cout << "Largest Integer is: ";

if (num2<=num3)
cin >> largest;
cout << "Largest Integer is: ";

if (num2<=num1)
cin >> largest;
cout << "Largest Integer is: ";

if (num3<=num1)
cin >> largest;
cout << "Largest Integer is: ";

if (num3<=num2)
cin >> largest;
cout << "Largest Integer is: ";

return 0;
}

i am trying to get the program to find the highest and lowest of the 3 numbers.. but when i run it its not doing so- i have 0 errors and 0 warnings

This post has been edited by fire21: 05 February 2007 - 12:41 AM

Is This A Good Question/Topic? 0

## Replies To: find the highest and lowest of 3 intergers

### #2 AmitTheInfinity

• C Surfing ∞

Reputation: 119
• Posts: 1,565
• Joined: 25-January 07

## Re: find the highest and lowest of 3 intergers

Posted 05 February 2007 - 01:10 AM

I am not sure about what are you trying to do in your code but This is something I would have done...

```cout<<"Enter Number 1 : ";
cin>>number1;
cout<<"Enter Number 2 : ";
cin>>number2;
cout<<"Enter Number 3 : ";
cin>>number3;

if(number1>=number2)
{
if(number1>=number3)
{
cout<<"Largest Number Is : "<<number1;
if(number2<=number3)
cout<<"Smallest Number Is : "<<number2;
else
cout<<"Smallest Number Is : "<<number3;
}
else
{
cout<<"Largest Number Is : "<<number3;
cout<<"Smallest Number Is : "<<number2;
}
}
else
{
if(number2>=number3)
{
cout<<"Largest Number Is : "<<number2;
if(number1<=number3)
cout<<"Smallest Number Is : "<<number1;
else
cout<<"Smallest Number Is : "<<number3;
}
else
{
cout<<"Largest Number Is : "<<number3;
cout<<"Smallest Number Is : "<<number1;
}
}

```

### #3 Louisda16th

• dream.in.assembly.code

Reputation: 15
• Posts: 1,967
• Joined: 03-August 06

## Re: find the highest and lowest of 3 intergers

Posted 05 February 2007 - 01:10 AM

I guess your having more of a logical error here. Your compiler will detect mainly syntax errors. Try this:
```if(num1<num2 && num1<num3)
{
/*num1 is smallest*/
}

```

Hope you get it. Try the rest of it yourself. It should be easy. You'll need a few more similar 'if' statement blocks.

EDIT: mmmm. I didn't realise this before. I was too slow for AmitTheInfinity.

This post has been edited by Louisda16th: 05 February 2007 - 08:52 AM

• D.I.C Regular

Reputation: 0
• Posts: 307
• Joined: 24-November 06

## Re: find the highest and lowest of 3 intergers

Posted 05 February 2007 - 08:39 AM

why are you reading in least after the if statement???
but Louisda16th is right and as he said using similar logic you'll get the program to be right

### #5 fire21

Reputation: 0
• Posts: 7
• Joined: 04-February 07

## Re: find the highest and lowest of 3 intergers

Posted 05 February 2007 - 10:12 AM

Thank You guys- just wanted a nudge on it and i got figured out.