Below is the body of a program I am trying to write. It is supposed to request a number of receipts, accept the receipt values and output the total amount, the average amount, and the highest and lowest amounts. I have created a program with an if ... else loop which does everything but figure out the lowest amount correctly. Can somebody help me figure what I'm missing? I have consulted many resources and the book I'm learning from sucks. I know it is probably something pretty simple. Any help would be greatly apprecriated. Thanks.
printf("how many rec. \n");
scanf("%d",&nr);
for ( i=0; i< nr; i++){
printf("Enter item# %d>",i+1);
scanf("%lf",&amt);printf("%6.2f\n",amt);
sum= sum + amt;
if (amt > highest)
highest = amt;
else if (amt <= highest)
lowest = amt
}
/***** prints the sum, the average, and the high and low amounts ***/
printf("-----\nyou spend $ %8.2f\n",sum);
average = sum/nr;
printf( "The average of your data is $%6.2lf\n", average);
printf( "The highest amount you entered is $%6.8f\n", highest);
printf( "The lowest amount you entered is $%6.8f\n", lowest);
}