Finding the lowest number

This is a discussion on Finding the lowest number within the C++ Programming forums, part of the General Programming Boards category; I searched this site and found some answers but still can't get this program to return the lowest number it ...

  1. #1
    Registered User
    Join Date
    Mar 2012
    Posts
    10

    Finding the lowest number

    I searched this site and found some answers but still can't get this program to return the lowest number it just keeps returning "int a" instead of the lowest number I can't seem to find what is wrong with it

    New to site and don't know how to properly display the code so I copied and paste it any help will be appreciated.
    Code:
    #include <iostream>
    
    
    using namespace std;
    
    
    int findLowest(int a, int b, int c, int d, int e);
    
    
    
    
    int main ()
    {
        int test1;
        int test2;
        int test3;
        int test4;
        int test5;
        int lowest;
    
    
        cout << "Enter first test score : ";
        cin >> test1; 
        cout << "Enter second test score: ";
        cin >> test2;
        cout << "Enter third test score : ";
        cin >> test3;
        cout << "Enter fourth test score: ";
        cin >> test4;
        cout << "Enter fifth test score : ";
        cin >> test5;
    
    
        lowest = findLowest(test1, test2, test3, test4, test5);
        
            cout << " Lowest number is: " << lowest << endl;
    
    
        return 0;
    }
    
    
    
    
    int findLowest(int a, int b, int c, int d, int e)
    
    
        {
            int low = a;
            if ( low > b)
            {
                b = low;
            }
            if (low > c)
            {
                c = low;
            }
            if (low > d)
            {
                d = low;
            }
            if (low > e)
            {
                e = low;
            }
    
    
         return low;
        }

  2. #2
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    All of your lines like b = low; are backwards. They should be like low = b;.
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

  3. #3
    Registered User
    Join Date
    Mar 2012
    Posts
    10
    That was it thank you very much. Surprising how something as simple as that can mess a whole program up lol. Thanks again!!

  4. #4
    Technical Lead QuantumPete's Avatar
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    894
    Quote Originally Posted by jonesk1978 View Post
    Surprising how something as simple as that can mess a whole program up lol.
    That's why you spent 70% of your time debugging, rather than writing code...
    "No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
    "Have you tried turning it off and on again?" - The IT Crowd

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. HELP: Exclude the highest and lowest number...
    By Ocin101 in forum C Programming
    Replies: 12
    Last Post: 07-21-2009, 01:51 AM
  2. Finding the lowest number of a certain input
    By theorbb in forum C Programming
    Replies: 26
    Last Post: 04-17-2006, 02:36 AM
  3. Finding lowest value
    By sloopy in forum C Programming
    Replies: 5
    Last Post: 11-26-2005, 09:48 AM
  4. Finding lowest value
    By titleist_03 in forum C++ Programming
    Replies: 8
    Last Post: 11-09-2004, 07:11 PM
  5. help with finding lowest number entered
    By volk in forum C++ Programming
    Replies: 12
    Last Post: 03-22-2003, 12:21 PM

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