The program is about getting the average of all laboratory exercise. I want to round off my decimals 7.7778 to the whole number. I tried the ceilf and roundf() its not working, is there any problem with my codes? any help will be appreciate thank you!
My codes
#include<stdio.h>
#include<conio.h>
#include <math.h>
int main()
{
int numberof_laboratory,lab_exercises,total_numberof_laboratory,average,roundoff;
char answer;
do
{
printf("\nEnter number of laboratory:");
scanf("%d",&numberof_laboratory);
for(int i=1;i<=numberof_laboratory;++i)
{
printf("\nEnter laboratory exercise %d:",i);
scanf("%d",&lab_exercises);
total_numberof_laboratory += lab_exercises;
average = total_numberof_laboratory / 3;
roundoff = ceilf(average * 100) / 100;
}
printf("The average laboratory exercise grade is %d",roundoff);
printf("\nDo you want to continue(Y/N)?");
scanf(" %c", &answer);
}
while(answer != 'N' && answer != 'n');
printf("Goodbye!");
}
Example
Enter number of laboratory:3
Lab exercise no 1: 10
Lab exercise no 2: 7
Lab exercise no 1: 6
The average laboratory exercise grade is: 7 // it should be 8