Off Topic > Off Topic

Programming Megathread

Pages: << < (132/241) > >>

--LegoPepper--:


--- Quote from: Ravencroft· on May 09, 2016, 02:40:42 PM ---
--- End quote ---
Did you initialize score[] properly?

Foxscotch:

first of all that's kinda hard to read. use more spaces ! ! and indent properly

min = score[0];
for (y = 1; y <= 9; y++)
{
    if (min > score[y])
    {
        min = score[y];
    }
}
cout << min;

anyway, I don't think we could reasonably figure out what's wrong without the rest of the code. we don't know what type min is or the items in the array, and I'm sure that could cause problems like this
also when I rewrote that stuff I begrudgingly used the same brace style you did, but nevertheless I want to expose you to this way too. just in case you like it better

for (int i = 0; i < 10; i++) {
    // stuff
}

Ravencroft·:

there are ten numbers between 21 and 99 in the array and min is a float. i tried it as an int but got the same outcome.

whats odd is if i change if(min>score[y]) to if(min<score[y]) it finds the max value without any issues.

Ravencroft·:

i figured it out. i had the input for the array starting at score[1] instead of score[0]

McJob:

Hey, quick note, could you append a '\n' or endl to the end of you cout input? Just that way it'll add a newline and the prompt won't run directly off your result.

Pages: << < (132/241) > >>

Go to full version