• C++ program to pick out the highest number out of a series

    ShikhaTan Member

    i just wanna know if there’s a way where i can pick out the highest number out of a series of them, so for example, i have like 1, 23, 34, 342, 1, 32,31, 21, 65 etc etc i wanna be able to just pick out the highest number from the above (the numbers are what’s outputted when i compile and run the program), I’m thinking of using an array, but i heard there’s another way i can do it:S its not meant to be a difficult thing, just beginner programming …

  • Abhey Member

    you just need to assign the numbers that are being returned into the array.
    find out how the numbers that are being returned are decelerated. and the simply input them in the array the same way that is shown above.
    so if x = 5 don’t do int Nbrs[] = { 5 }, but do int Nbrs[] = { x }. (crudely speaking)

    hope I’m on the right track, cause I’m not sure what you mean.

  • ShikhaTan Member

    all those functions you wrote already exist in the stl….learn the stl if you want to call yourself a c++ programmer. No point in reinventing the wheel, and all stl containers and algorithms by standard enforce certain run times (which are generally fast) and can even be faster (ie. sorts in stl are usually O(n logn) complexity, while above example is O(n^2))

  • ShikhaTan Member

    yeah i know what void is, i just use it whenever i make my own function, like I’ve never seen it used for main() , that confused me heaps.. nah i prefer to use using namespace std; .. it just confuses me otherwise

Viewing 3 reply threads
  • You must be logged in to reply to this topic.
en_USEnglish