Edit
#include <stdio.h>
int main(void) {
// total number of students
int totalStudents = 10;
// number of loaves sold per student
int loavesSold[totalStudents];
// total number of loaves sold
int totalLoavesSold = 0;
// loaf price
double loafPrice = 1.4;
// ask user to enter number of loaves sold for each students
for (int i = 0; i < totalStudents; ++i) {
printf("Enter number of sold loaves for student #%i: ", i+1);
scanf("%i", &loavesSold[i]);
// calculate total
totalLoavesSold += loavesSold[i];
}
// print total number
printf("Total number sold: %d\n", totalLoavesSold);
// print revenue
printf("Revenue: %.2f\n", totalLoavesSold * loafPrice);
// print average number
printf("Average number: %d\n", totalLoavesSold / totalStudents);
return 0;
}
Comments
Leave a comment