Skip to content

Instantly share code, notes, and snippets.

@faisal95bd
Last active April 13, 2022 07:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save faisal95bd/ccc643797681b1a2c72f9c0ba45ef5b4 to your computer and use it in GitHub Desktop.
Save faisal95bd/ccc643797681b1a2c72f9c0ba45ef5b4 to your computer and use it in GitHub Desktop.
Calculate the total distance travelled with the formula (s = ut+1/2at2)
#include<stdio.h>
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