Thread: Greatest of Three Integers Program

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    6

    Greatest of Three Integers Program

    Hey Guys,

    I'm new to programming and am really stumped on how to write a program on figuring out the greates of three integers and could really use someone's help.

    Thanks a lot guys!!
    Tony

  2. #2
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,534
    Read this and this, and then this. After you have made your attempt, post your code, and post it up here in this thread.

    ~/

  3. #3
    Bob Dole for '08 B0bDole's Avatar
    Join Date
    Sep 2004
    Posts
    618
    Code:
    if(x > y && x > z)
        greatest = x;
    if(y >x && y > z)
        greatest = y;
    if(z > x && z > y)
        greatest = z;
    I think something like that might work, been a couple years :-p
    Hmm

  4. #4
    Registered User
    Join Date
    Sep 2005
    Posts
    6
    Quote Originally Posted by kermit
    Read this and this, and then this. After you have made your attempt, post your code, and post it up here in this thread.

    ~/
    I looked under the tutorials but I'm not too sure what I should be looking for.

  5. #5
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    Or you can turn this into your teacher, and get an F:
    Code:
    int returnLargest(int a, int b, int c)
    {
    	return (((a > b) ? a : b) < c) ? c : ((a > b) ? a : b);
    }

  6. #6
    Registered User
    Join Date
    Sep 2005
    Posts
    6
    Quote Originally Posted by B0bDole
    Code:
    if(x > y && x > z)
        greatest = x;
    if(y >x && y > z)
        greatest = y;
    if(z > x && z > y)
        greatest = z;
    I think something like that might work, been a couple years :-p
    I LOVE YOU!!!!!!!
    I LOVE YOU!!!!!!!
    I LOVE YOU!!!!!!!
    I LOVE YOU!!!!!!!
    I LOVE YOU!!!!!!!
    I LOVE YOU!!!!!!!
    I LOVE YOU!!!!!!!
    I LOVE YOU!!!!!!!

  7. #7
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    Quote Originally Posted by B0bDole
    Code:
    if(x > y && x > z)
        greatest = x;
    if(y >x && y > z)
        greatest = y;
    if(z > x && z > y)
        greatest = z;
    I think something like that might work, been a couple years :-p
    What does greatest equal if x = 5, y = 5, and z = 4?

  8. #8
    ~Team work is the best!~ wakish's Avatar
    Join Date
    Sep 2005
    Posts
    85
    definetly that's not the best way to do it...
    instead just try with a few 'if-else' statements,it would be more clear and easy to follow...

  9. #9
    Bob Dole for '08 B0bDole's Avatar
    Join Date
    Sep 2004
    Posts
    618
    >What does greatest equal if x = 5, y = 5, and z = 4?

    I'm not trying to get him an A or anything :-p
    Hmm

  10. #10
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > I'm not trying to get him an A or anything
    A today
    F tomorrow
    It all balances out in the end.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can someome help me with a program please?
    By WinterInChicago in forum C++ Programming
    Replies: 3
    Last Post: 09-21-2006, 10:58 PM
  2. Need help with my program...
    By Noah in forum C Programming
    Replies: 2
    Last Post: 03-11-2006, 07:49 PM
  3. Why is this program converting to integers
    By 3DPhreak in forum C++ Programming
    Replies: 3
    Last Post: 05-31-2004, 09:44 AM
  4. Replies: 2
    Last Post: 05-10-2002, 04:16 PM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM