SHARE
TWEET

Untitled

a guest Mar 23rd, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.  
  10. void force(double m, double accel);
  11.     /* Moved everything so it is under the void force() */
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top