Greatest of Three Integers Program

This is a discussion on Greatest of Three Integers Program within the C Programming forums, part of the General Programming Boards category; Hey Guys, I'm new to programming and am really stumped on how to write a program on figuring out the ...

  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,528
    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,265
    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,265
    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
    32,855
    > 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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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, 11: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, 10:44 AM
  4. Replies: 2
    Last Post: 05-10-2002, 05:16 PM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 11:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21