0

I need help with a loop.

#include <stdio.h> int main() { double H,h; printf("Give a starting height\n"); scanf("%lf",&H); if(H>0.2) { do {h=(2/3)*H; printf("h=%d",h);}while(h>0.2); } } We drop a ball from a starting height,i want to find all the heights the ball will reach and show it to me except below 0.2 m where it stops bouncing. At this point i am pressing random things,any help would be appreciated.

28th Nov 2019, 5:08 PM
Kos
2 Antworten
+ 2
'h=(2/3)*H' is equivalent to 'h=0' as (2/3) will return 0, so after correcting it by using 2.0 or 3.0 or both, and correcting other syntax error like forgetting return 0; in end of main method. Now if there is some logical error in your program then only it may not work as it is supposed to do else it is fine.
28th Nov 2019, 6:31 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
0
Can you explain it with some numbers because the question is not clear.
28th Nov 2019, 5:16 PM
Avinesh
Avinesh - avatar