the code is pretty much a mess because i've been trying everything to figure this out on my own. every time i compile and test the program, no matter what values i put in i end up with 0.0 for the acceleration answer.
i needed at least 1 user defined function for the problem i'm doing or else it would all be in the main.
any help will be greatly appreciated.Code:#include <stdio.h> double calc_answer(double, double, double); /*User defined function*/ double show_answer(double); /*User defined function*/ int main(void) { double vi=0, /*initial velocity input in meters per second*/ vf=0, /*final velocity input in meters per second*/ time=0, /*time input in seconds*/ accel1=0, /*acceleration calculation*/ accel=0; /*acceleration output in meters per second squared*/ printf("\n All values in seconds, meters per second, or meters per second squared"); printf("\n Please enter the initial velocity:"); /*input initial velocity*/ scanf("%lf", &vi); printf("\n Please enter the final velocity:"); /*input final velocity*/ scanf("%lf", &vf); printf("\n Please enter the time:"); /*input time*/ scanf("%f", &time); calc_answer(vi, vf, time); show_answer(accel); return(vi, vf, time); } double calc_answer(double vi, double vf, double time) { double accel1, /*acceleration part 1*/ accel; /*final acceleration calculation value*/ accel1 = vf-vi; /*Calculation of acceleration part 1*/ accel = accel1/time; /*final calculation of acceleration*/ return(accel); } double show_answer(double accel) { printf("\n The acceleration is %.1lf \n\n\n\n", accel); return; }



LinkBack URL
About LinkBacks


