Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- /* This program takes two inputs acceleration
- and mass, and ouputs the force = mass*acceleration */
- void force(double m, double accel);
- int main() {
- /* Added accel */
- double mass, accel;
- /* Changed %d to %lf since it is declared with double */
- printf("Enter an acceleration: ");
- scanf("%lf", &accel);
- /* Changed %d again to %lf for the same reason as above */
- printf("Enter the mass of the object: ");
- scanf("%lf", &mass);
- force(mass, accel);
- printf("You entered %lf m/s^2\n", accel);
- printf("You entered %lf kg\n", mass);
- return 0;
- }
- /* Declared mass too */
- void force(double m, double accel, double mass) {
- mass = m / 1000;
- printf("The force is %lf milliNewtons\n", mass * accel);
- accel = accel*1000;
- printf("The force is %lf Newtons\n\n", mass * accel);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement