Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Please review my code
- #include <stdio.h>
- #include <math.h>
- main()
- {
- int students, i = 0;
- float average, total = 0.0, sum = 0.0, num;
- float *costs;
- prinf("Enter the number of students: ");
- scanf("%d\n",students);
- while(students != 0){
- costs = malloc(students*sizeof(double));
- while(i < students){
- scanf("%f",&num);
- sum += num;
- costs[i++] = num;
- } average = sum/students;
- for(i = 0; i < students; i++){
- total += floor((costs[i] - average)*100)/100;
- } printf("%f",total);
- i = 0;
- sum = 0.0;
- total = 0.0;
- free(costs);
- prinf("Enter the number of students: ");
- scanf("%d\n",students);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement