Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 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. void force(double m, double accel);
  10.  
  11. int main() {
  12. /* Added accel */
  13. double mass, accel;
  14. /* Changed %d to %lf since it is declared with double */
  15. printf("Enter an acceleration: ");
  16. scanf("%lf", &accel);
  17. /* Changed %d again to %lf for the same reason as above */
  18. printf("Enter the mass of the object: ");
  19. scanf("%lf", &mass);
  20.  
  21. force(mass, accel);
  22.  
  23. printf("You entered %lf m/s^2\n", accel);
  24. printf("You entered %lf kg\n", mass);
  25.  
  26. return 0;
  27. }
  28.  
  29. /* Declared mass too */
  30. void force(double m, double accel, double mass) {
  31. 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