Min and max in C using basics

前端 未结 4 1185
鱼传尺愫
鱼传尺愫 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.

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题