Finding max value in an array

后端 未结 5 966
闹比i
闹比i 2021-01-07 13:57
int highNum = 0;
int m;
int list[4] = {10, 4, 7, 8};
    for (m = 0 ; m < size ; m++);
    {
        if (list[m] > highNum)
            highNum = list[m];
             


        
5条回答
  •  攒了一身酷
    2021-01-07 14:33

    There is a ; right after the closing parentheses of your for loop: for (m = 0 ; m < size ; m++);

    The statements inside the block (inside the curly braces) gets executed only after the loop do nothing for size number of times and that too only once.

    You have also missed a pair of { ... } for the if statement as well.

提交回复
热议问题