Question: C programming. Almost finished with my project, but I'm not sure how to get the numbers to stop rounding. (ex. if i need 36.97 the

C programming. Almost finished with my project, but I'm not sure how to get the numbers to stop rounding. (ex. if i need 36.97 the program will spit out 36.00). Thank you in advance

#include

int main() {

int age; int count = 0; int sum =0; int smallAge = 0; int largeAge = 0; double avg = 0.00; do { printf("Please enter an age (0-120), enter -1 to finish: "); scanf("%d", &age); //printf("%d ", age); if (age == -1) { //printf("Invalid input, exiting "); break; }

if(count==0){ smallAge = age; largeAge = age; } if (age > largeAge) { largeAge = age; } if (age < smallAge) { smallAge = age; } if (age <= 120 && age >= 0) { sum += age; count++; } //sum += age; // count++; } while (age != -1);

//avg =(double) sum / count; avg = sum / count;

//printf(" "); printf("The smallest entered age is %d. ",smallAge); printf("The largest entered age is %d. ",largeAge); printf("The average age is %.2lf. ",avg);

return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!