2 largest number,3 variables only

This is a discussion on 2 largest number,3 variables only within the C++ Programming forums, part of the General Programming Boards category; Say you input 10 different numbers, it should determine the two largest number.Can you do it with 3 variables only?The ...

  1. #1
    Registered User
    Join Date
    Jul 2008
    Posts
    91

    2 largest number,3 variables only

    Say you input 10 different numbers, it should determine the two largest number.Can you do it with 3 variables only?The variables should be: counter -( for the loop), number - (input),largest - (largest number so far).

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Eh, you want to find largest and the second largest number, and only use a number, counter and largest variable? I doubt you can do that. [Assuming of course that none of the variables are pointers to more than one of it's type or arrays, that is].

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Jul 2008
    Posts
    91
    Im happy to here that

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 22
    Last Post: 05-29-2009, 05:44 PM
  2. largest and smallest number
    By wise_ron in forum C Programming
    Replies: 11
    Last Post: 10-05-2006, 03:25 PM
  3. Find largest and second largest number (help)
    By Arkon in forum C++ Programming
    Replies: 6
    Last Post: 01-20-2006, 10:21 PM
  4. how do u find 2nd largest number??
    By juancardenas in forum C Programming
    Replies: 8
    Last Post: 02-14-2003, 07:28 AM
  5. Learning arrays
    By Unregistered in forum C Programming
    Replies: 4
    Last Post: 07-09-2002, 10:27 PM

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