Join the social network of Tech Nerds, increase skill rank, get work, manage projects...

• # How to fix my code in C language programming @NeedHelpinCoding • 0
• 0
• 0
• 0
• 0
• 0
• 0
• 250

Hello i am doing an exercise that states:

A 3000 lb  vehicle travelling on a road at 100 ft/sec requires a force equal to its mass times its acceleration to stop ( F = ma).

The acceleration is given by

a=  (v_o^2-v_i^2)/2d

Where  vi = 100 ft/sec

vo = 0 ft/sec.

Write a program that will calculate the retarding force needed to stop the car at distances of 10, 20, 30, 40, 50, …, 1000 ft. Display the distance value and the corresponding retarding force in tabular form. The units of force are Newtons (N). Your solution must include a user-defined function that returns the force and takes as input initial and final velocity and distance.

double force(double velocityInitial, double velocityFinal, double distance, double mass);

I have tried the following:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

double force(double velocityInitial, double velocityFinal, double distance, double mass);

int main()
{

double forceFormula;
int distance, mass, acceleration;

forceFormula = mass * acceleration;

printf("\nDistance:\t\tForce in Newtons:\n"
"------------------------------------------\n");
printf("%d\t\t\t%.2lf\n", distance, forceFormula);
printf("------------------------------------------\n");

return 0;
}

double force(double velocityInitial, double velocityFinal, double distance, double mass)
{
velocityInitial = 100;
velocityFinal = 0;
mass = 3000;

double acceleration, forceFormula;

for( distance = 10; distance <= 1000; distance += 10)
{

acceleration = ((velocityFinal * velocityFinal) - (velocityInitial * velocityInitial))/ 2 * distance;

forceFormula = mass * acceleration;
}

return forceFormula;

}

I am not sure where it is that I am making a mistake, if its in the variables, the function definition... I really appreciate the help, thanks.

OR
OR
Register

OR
Fill out the form below and instructions to reset your password will be emailed to you:

• Hire
• Post Projects

### Post Projects

• All at 0 Cost ....
• Post Tech Job
• Select Best Bidder
• Track the Project
• Approve Work and Pay safely
• Browse Nerds
• Work
• Find Projects Find Projects
• UI Design and UX
• Software Engineering
View more...
View less...
• Marketing
• General
View more...
View less...
• Manage
• Company Company

### Manage Company

• All at 0 Cost ....
• Manage Company and Employee Profiles
• Company wide Employee Productivity Reports
• Knowledge Sharing and Collaboration Tools
• Get Sales Lead and Bid for Tech Projects
• Send Invoices and Receive Payment Safely
• Learn
• Nerd Digest Nerd Digest
• UI Design and UX
• Software Engineering
View more...
View less...
• Marketing
• General
View more...
View less...
• Tech Q & A Tech Q & A
• UI Design and UX
• Software Engineering
View more...
View less...
• Marketing
• General
View more...
View less...