Click here to Skip to main content
15,899,026 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
#include<stdio.h>
float avg_mileage(float start_mileage,float end_mileage);
void main()
{ float start_mileage,end_mileage,avg;
printf("Enter the starting mileage\n");
scanf("%f",&start_mileage);
printf("Enter Ending Mileage\n");
scanf("%f",&end_mileage);
avg=average_mileage(start_mileage,end_mileage);
printf("%fThe average mileage is\n", avg);
}
float average_mileage(float start_mileage,float end_mileage)
{float dt;
float total=1000;
float avg;
dt=start_mileage-end_mileage;
avg=dt/total;
return avg;
}
Posted
Comments
[no name] 5-Sep-14 10:29am    
It's usually customary to ask a question or describe a problem instead of just dumping your code here. What type mismatch error? Where? What is your compiler telling you? The only thing I see is a mismatch between your function prototype and the implementation.

1 solution

You are happily ignoring the C programming language rules, for instance that function name in the declaration must match the one in the definition. Try:
C
#include<stdio.h>
float average_mileage(float start_mileage,float end_mileage);
int main()
{ float start_mileage,end_mileage,avg;
printf("Enter the starting mileage\n");
scanf("%f",&start_mileage);
printf("Enter Ending Mileage\n");
scanf("%f",&end_mileage);
avg=average_mileage(start_mileage,end_mileage);
printf("The average mileage is %f\n", avg);
return 0;
}
float average_mileage(float start_mileage,float end_mileage)
{float dt;
float total=1000;
float avg;
dt=start_mileage-end_mileage;
avg=dt/total;
return avg;
}
 
Share this answer
 
Comments
Maverick Mishra 9-Sep-14 10:33am    
damn same mistake twice...thanks anyways...
CPallini 9-Sep-14 13:31pm    
You are welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900