Question #142622

) Write a function that counts the number of bounces a ball makes before it stops and rests on the
ground. Assume that with each bounce, it reaches up to 0.9 of its previous bounce. The ball is
considered at rest when it is at height less than 0.4 cm. Let the user input the initial height from the

Expert's answer

int calculateBounceCnt(){
    float height = 0.0;
    int bounces = 0;
    printf("Enter the initial height: ");
    scanf("%f", &height);
    while (height >= 0.4){
        height *= 0.9;
        bounces++;
    }
    printf("The number of bounces is: %d\n", bounces);
    return bounces;
}
LATEST TUTORIALS
APPROVED BY CLIENTS