Answer to Question #142622 in C for unknown

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
1
Expert's answer
2020-11-05T12:47:01-0500
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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS