Min and max in C using basics

前端 未结 4 1154
鱼传尺愫
鱼传尺愫 2021-01-24 22:04

This program is supposed to end when the user enters 0 and then show the count, sum, average, min and max. I am able to figure out the sum count and average but my min and max i

4条回答
  •  走了就别回头了
    2021-01-24 22:40

    First, initialize min and max with proper values.

    int min = INT_MAX;
    int max = INT_MIN;
    

    Second, update min only when the input number less than current min. Update max only when the input number is greater than the current max.

提交回复
热议问题