Getting the min, max, and ave of the five numbers inputted

无人久伴 提交于 2019-12-07 04:07:28

Since this is a learning exercise, I wouldn't correct your code, but point out what needs to be fixed:

  • Arrays in C are indexed from zero, not from one, so the counter should go from 0 to 4, inclusive
  • min is an int, while num is an array, so the assignment min=num is invalid
  • scanf should put the data into &num[count], not &num[5]
  • In the way that you coded your loop you do not need an array at all: you need the last number entered.
  • total cannot be computed as min+max; you need to keep a running total, updating it on each iteration.
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!