i need help

Discussion in 'C++' started by h168210@gmail.com, Oct 22, 2006.

1. Guest

hi,i have a aquestion that i don't know how to compare the smallest and
the largest between five intergers.could anyone help me,thanks.

, Oct 22, 2006

2. PhlipGuest

h168210 wrote:

> hi,i have a aquestion that i don't know how to compare the smallest and
> the largest between five intergers.could anyone help me,thanks.

Sit down with your tutorial and read it, from the front cover, until you are
(Especially to post!

--
Phlip
http://www.greencheese.us/ZeekLand <-- NOT a blog!!!

Phlip, Oct 22, 2006

3. David HarmonGuest

On 21 Oct 2006 20:36:19 -0700 in comp.lang.c++,
wrote,
>hi,i have a aquestion that i don't know how to compare the smallest and
>the largest between five intergers.could anyone help me,thanks.

Show the code that you have written. Describe how the result
differs from what you wanted. Ask specific questions.

This issue is covered in Marshall Cline's C++ FAQ. See the topic
"[5.2] How do I get other people to do my homework problem for me?"
It is always good to check the FAQ before posting. You can get the
FAQ at:
http://www.parashift.com/c++-faq-lite/

See the welcome message posted twice per week in comp.lang.c++ under
the subject "Welcome to comp.lang.c++! Read this first." or
available at http://www.slack.net/~shiva/welcome.txt

David Harmon, Oct 22, 2006
4. Daniel T.Guest

Daniel T., Oct 22, 2006
5. Jim LangstonGuest

<> wrote in message
news:...
> hi,i have a aquestion that i don't know how to compare the smallest and
> the largest between five intergers.could anyone help me,thanks.

Few ways to do it, depending on how you want to go. Simple way is put them
into a sorted contain, and then get the largest and the smallest.

Another way, put them in some type of container (array, vector, etc..) and
use a for loop going through each one comparing if it's smaller or greater
than saved values.

Sounds like a homework question, so I'm not going to give you any code.

Jim Langston, Oct 22, 2006
6. Salt_PeterGuest

wrote:
> hi,i have a aquestion that i don't know how to compare the smallest and
> the largest between five intergers.could anyone help me,thanks.

Forget the smallest and the largest of 5 integers.

How do you declare an integer variable and initialize it?
How do you then compare 2 variables?
Show the code.

Salt_Peter, Oct 22, 2006
7. Guest

wrote:
> hi,i have a aquestion that i don't know how to compare the smallest and
> the largest between five intergers.could anyone help me,thanks.

The smallest will always be smaller than the largest, unless all five
integers are equal, in which case the smallest is equal to the largest.
Easy!

, Oct 22, 2006
8. Mike WahlerGuest

<> wrote in message
news:...
> hi,i have a aquestion that i don't know how to compare the smallest and
> the largest between five intergers.could anyone help me,thanks.

int main()
{
int i[] = {1, 2, 3, 4, 5}; /* five integers */
i[0] == i[4]; /* compare smallest with largest */
return 0;
}

-Mike

Mike Wahler, Oct 22, 2006
9. EricGuest

Mike Wahler wrote:
> <> wrote in message
> news:...
>> hi,i have a aquestion that i don't know how to compare the smallest and
>> the largest between five intergers.could anyone help me,thanks.

>
> int main()
> {
> int i[] = {1, 2, 3, 4, 5}; /* five integers */
> i[0] == i[4]; /* compare smallest with largest */
> return 0;
> }
>
> -Mike
>
>

I bet you could have worked "between" in somehow.

Eric, Oct 22, 2006