+ 1
Hi! if i want to get largest value with using while how ? and what is the problem with my porgram i want to get the Max value .
#include<stdio.h> #include<math.h> int main () { int n,i; double value,max,sum,avg; printf("Enter how many values to consider :"); scanf("%d",&n); if(n>0){ i=1; sum=0; while(i<=n){ printf("Enter value %d:",i); scanf("%lf",&value); sum=sum+value; max=value; if(value>max) max=value; i++; } avg=sum/n; printf("Largest value= %.2f\n",max); printf("average=%.2f",avg); } else printf("ERROR"); return 0; }
2 Réponses
+ 1
thank you very much
0
you have 2 assignments "max=value". remove the upper one, then it should work