Skip to content

Instantly share code, notes, and snippets.

Last active April 13, 2022 07:15
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Calculate the total distance travelled with the formula (s = ut+1/2at2)
int main() {
float u, a, t, s; // variable declaration
// input statement which take the values
printf("\n Enter initial velocity: ");
scanf("%f", & u);
printf("\n Enter acceleration: ");
scanf("%f", & a);
printf("\n Enter time required: ");
scanf("%f", & t);
s = (u * t) + ((a * t * t) / 2); // the formula
printf("\n \n The displacement is : %f \n \n", s); // printing the result
return 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment