after i run the program, when i enter an integer number it asks me to calculate V for velocity or T for time but when i enter v or t id does not accept it
Write a complete C program that performs gravity calculations based on Isaac Newton's law of universal gravitation. Your program must do this:
- How long (in seconds – 2 decimal places) does it take an object to fall distance d? (d, in meters, being entered by the user at the keyboard).
- What is the velocity (in meters per second – 2 decimal places) of an object that has traveled d meters?
- Ask the user for the desired computation (1) for time, (2) for velocity and (3) to end program.
- Your program must return to the choices until the user enters option (3).
Code:
int
main()
{
char variable;
int d= 0.0;
float sqvelocity =0.0;
float sqtime =0.0;
printf("Enter a value for distance:");
scanf("%d",&d);
printf("Enter variable for desired computation, v (velocity) or t (time):");
scanf("%c", &variable);
if (variable == 'v')
printf("the velocity is: %lf.\n", sqvelocity);
else
if (variable == 't')
printf("the time is: %lf.\n", sqtime);
sqvelocity= sqrt(2*9.8*d);
sqtime= sqrt((2*d)/9.8);
return (0);
}
Hello admins would you delete my post.
NO!
Thanks