The program I am writing displays the velocity and acceleration when the user inputs time.
The code I have thusfar is:
#include <stdio.h>
#include <math.h>
int main (void)
{
int time,velocity, acceleration;
printf ("Please input time in seconds: \n");
scanf_s("%d" , &time);
velocity = 0.00001* pow(time,3)-.00488* pow (time,2)+.75795*time+181.3566;
acceleration = 3-0.000062*pow(velocity,2);
printf ("Velocity: ""%d\n",velocity);
printf ("Acceleration: ""%d\n",acceleration);
return 0;
}
The answer displays, but I can't get it to display the decimals. It only shows whole numbers.
I tried replacing int with float, but then it shows a completely wrong answer. I also changed the %d to %f and still shows the problem.
I believe I am declaring wrong.
I also tried %5.3f......but the answer comes out completely wrong.
Can anyone help me, I tried...hence the code I am posting ;)
:D