#include <stdio.h>
#include <stdlib.h>
#include<math.h>
#define pi 3.1416
#define brkFactor 0.7
int main()
{
double slopeRad,slopeTan,roadSlope,skidLength,speedCar;
char carModel[200];
printf("Enter the name of the car model\n");
scanf("%s",carModel);
printf("Enter the skid length\n");
scanf("%d",&skidLength);
printf("Enter the roadSlope\n");
scanf("%d",&roadSlope);
slopeRad = roadSlope*(pi/180);
slopeTan= sin(slopeRad)/ cos(slopeRad);
speedCar = sqrt(30*skidLength*(slopeTan+brkFactor);
printf("the slope rad is %f\n",slopeRad);
printf("the slope tan is %f\n",slopeTan);
printf("The %s has a speed of %d ;\n",carModel,speedCar);
system("pause");
return 0;
}
OK seriously need DIRECT HELP
Started by russian777, Nov 25 2008 04:13 PM
1 reply to this topic
#1
Posted 25 November 2008 - 04:13 PM
So i been trying to debug this and yet i am still getting a 0.00000 value , so if anyone can jus alter this code and post it back up as an entire programme it would be helpfull.
|
|
|
#2
Posted 25 November 2008 - 04:26 PM
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define pi 3.1416
#define brkFactor 0.7
int main()
{
double slopeRad,slopeTan,roadSlope,skidLength,speedCar;
char carModel[200];
printf("Enter the name of the car model\n");
scanf("%s",carModel);
printf("Enter the skid length\n");
scanf("%lf",&skidLength);
printf("Enter the roadSlope\n");
scanf("%lf",&roadSlope);
slopeRad = roadSlope*(pi/180);
slopeTan= sin(slopeRad)/ cos(slopeRad);
speedCar = slopeRad+slopeTan;
printf("the slope rad is %lf\n",slopeRad);
printf("the slope tan is %lf\n",slopeTan);
printf("The %s has a speed of %lf ;\n",carModel,speedCar);
return 0;
}
You are using %d to doubles. %d is a decimal.
For floats use %f and for doubles use %lf


Sign In
Create Account


Back to top









