In this program, the float array purchases[2] value is 90.50 but when I run the code it changes from 90.50 to 90.5010.990000. Why? purchases[0] and purchases[1] print fine.
#include <stdio.h>
int main() {
float purchases[3] = {10.99, 14.25, 90.50};
float total = 0;
int k;
//Total the purchases
printf("%.2f %.2f %.2f", purchases[0], purchases[1], purchases[2]); // Just so I know whats going on
for (k = 0; k < 3; k++) {
total += purchases[k];
printf("%f\n", total); // Just so I know whats going on
printf("%d\n", k); // Just so I know whats going on
}
printf("Purchases total is %6.2f\n", total);
}