I have two programs here I cannot seem to get any return value and I have no idea why, everything I'm doing is just like my book says and I cannot get it working.
The parts commented out are the other ways I was trying to make this work, somethings wrong because they're both not working
This one convert miles to kilometer as many times and increment value you select
int main(int argc, char *argv[])
{
void conversions(double, int, double); //prototypes
double milesToKm(double);
double miles = 0;
int conv = 0;
double inc = 0;
printf("Enter the miles:\n");
scanf("%d", &miles);
printf("Enter the number of times you want to be converted:\n");
scanf("%d", &conv);
printf("Enter the increment between conversions:\n");
scanf("%d", &inc);
conversions(miles, conv, inc);
system("PAUSE");
return 0;
}
void conversions( double miles, int conv, double inc)
{
int i;
double km;
printf("MILES KILOMETERS\n");
printf("----- ----------\n");
for (i = 0; i < conv; i++){
km = milesToKm(miles);
printf("%3.2d %6.2d\n", miles, km);
// printf("%3.2d %6.2d\n", miles, milesToKm(miles));
miles += inc;
}
}
double milesToKm(double miles)
{
double km;
km = miles * 1.6093;
// return miles * 1.6093;
return (km);
}
This one is to calculate win percentage
int main(int argc, char *argv[])
{
double winPercent(double, double);
double win, loss;
double perWin;
printf("Enter the number of wins:\n");
scanf("%d", &win);
printf("Enter the number of losses:\n");
scanf("%d", &loss);
perWin = winPercent(win, loss);
printf("The win percentage is: \n", perWin);
system("PAUSE");
return 0;
}
double winPercent(double win, double loss)
{
double percWin;
percWin = (100 * win / (win + loss));
return (percWin);
}
Any help is appreciated, I cannot see anything wrong is my code from what has been taught.