Code:
#include <stdio.h>
#define GRAVITY 16
int main(void) {
int time, altitude, new_alt;
time=1;
printf("What is the altitude you are dropping your object from?\n");
scanf("%d", &altitude);
printf("Time Altitude\n");
// Loop until altitude reaches zero.
while (new_alt >= 0) {
// Calculate the new altitude.
new_alt = altitude-GRAVITY*time*time;
// Print out the table of time and altitude.
printf("%d %d\n", time,new_alt);
time++; // Go to the next time value.
}
return 0;
the last one prints 3 seconds -24 altitude. i need all values below 0 to print as 0. How do I do that?