Compile both programs with -lm option.
gcc pts.c -lm
gcc stp.c -lm
* takes the top speed as input and outputs the bhp
*/
#include <stdio.h>
#include <math.h>
main(int argc, char *argv[])
{
float speed;
if(argc != 2)
{
fprintf(stderr," Usage : %s topSpeed\n", argv[0]);
exit(1);
}
speed = atof(argv[1]);
speed /= 18;
speed *= 5;
printf("The BHP is %f\n",
speed*speed*speed*0.0004861);
}
main(int argc, char *argv[])
{
float bhp, speed;
if(argc != 2)
{
fprintf(stderr," Usage : %s bhp\n", argv[0]);
exit(1);
}
bhp = atof(argv[1]);
/*
* divide the bhp by
our constant and then find the cube root
*/
speed = cbrt(bhp/0.0004861);
/*
* convert into kmph
*/
speed *= 18;
speed /= 5;
printf("The top speed is
%d kmphr\n", (int)speed);
}