Connect with us

Min-Max Code Problem.

Discussion in 'Microcontrollers, Programming and IoT' started by [email protected], Nov 24, 2011.

Scroll to continue with content
  1. Richard@EELTD

    [email protected]

    Apr 1, 2011
    I've been working on a code to take the max and min of 11 user inputted numbers, but I can't get the code to work.

    I was wondering if anyone here could help me troubleshoot the code :)

    #include <stdio.h>
    int max, min;
    int a,b,c,d,e,f,g,h,i,j,k;
    MAXMIN(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k, int min, int max)
    min=(std::min a,b,c,d,e,f,g,h,i,j,k);
    max=(std::max a,b,c,d,e,f,g,h,i,j,k);
    int a,b,c,d,e,f,g,h,i,j,k;
    int min, max;
    printf ("Enter an integer number.\n");
    printf ("Enter a second integer number.\n");
    printf ("Enter a third integer number.\n");
    printf ("Enter a fourth integer number.\n");
    printf ("Enter a fifth integer number.\n");
    printf ("Enter a sixth integer number.\n");
    printf ("Enter a seventh integer number.\n");
    printf ("Enter an eighth integer number.\n");
    printf ("Enter a ninth integer number.\n");
    printf ("Enter a tenth integer number.\n");
    printf ("Enter a eleventh integer number.\n");
    printf("The minimum of your inputted numbers is "%d"\n",&min);
    printf("The maximum of your inputter numbers is "%d"\n",&max);

    Thanks in advance.
  2. daddles


    Jun 10, 2011
    Please use CODE tags for your code. Most programmers hate to look at flat code.

    You also don't say what language or compiler you're using. It looks like it might be C or C++; however, your code won't compile with either compiler. I suggest never posting code that can't compile (unless your problem is that you can't figure out why it won't compile).

    I see lots of errors in your code, so first focus on posting something that compiles and demonstrates the error you're getting. Also state what compiler you're using along with examples of the input you gave and the output you got. If you're not willing to go to this trouble, you'll find fewer people who are willing to respond, at least in my experience.

    Finally, you need to learn how to reduce your problem to its essence. In this case, it means removing all the fluff that's not needed to exhibit the problem. That would mean to e.g. start with only gathering two or three numbers first. That cuts the number of lines down by roughly a half.
  3. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    Jan 21, 2010
    In this case an additional useful thing would be an image (or some other log) of the program running showing the numbers being entered and the result being printed.

    You should compare the way you call your maxmin routine with how you define it.

    Some compilers would give errors, some warnings, and others would silently let you do it. I'm wondering what you have?
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day