Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. /*-----------------------------------------------------------------------------
  2. - SE 185 Lab 05
  3. - Developed for 185-Rursch by T.Tran and K.Wang
  4. -----------------------------------------------------------------------------*/
  5. #include <stdio.h>
  6. /* This program takes two inputs acceleration
  7. and mass, and ouputs the force = mass*acceleration */
  8.  
  9. /* Got rid of this void force() */
  10. /* void force(double m, double accel); */
  11.  
  12. int main() {
  13. /* Added accel */
  14. double mass, accel;
  15. /* Changed %d to %lf since it is declared with double */
  16. printf("Enter an acceleration: ");
  17. scanf("%lf", &accel);
  18. /* Changed %d again to %lf for the same reason as above */
  19. printf("Enter the mass of the object: ");
  20. scanf("%lf", &mass);
  21.  
  22. force(mass, accel);
  23.  
  24. printf("You entered %lf m/s^2\n", accel);
  25. printf("You entered %lf kg\n", mass);
  26.  
  27. return 0;
  28. }
  29.  
  30. void force(double m, double accel) {
  31. double mass = m / 1000;
  32.  
  33. printf("The force is %lf milliNewtons\n", mass * accel);
  34.  
  35. accel = accel*1000;
  36.  
  37. printf("The force is %lf Newtons\n\n", mass * accel);
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement