Convert Yard and Feet to Miles coderinme

Convert Yard and Feet to Miles coderinme

Convert Yard and Feet to Miles coderinme
In this we are going to convert yard and feet into miles. Before that we need to know the relation among these.
There are 5280 feet per mile
There are 3 feet in a yard.

Let’s write a function that takes input of yards and feet (whole numbers) and calculate and returns an output of the total number of miles(a floating-point value). As we know there are 5280 feet per mile. Also there are 3 feet in a yard. So Using appropriate parameter passing and appropriate return mechanism, appropriate data types, we shall code for this.
For example, with inputs of 1760 yard and 1320 ft, the result would be 1.25 miles. Call this function from the main program with different set of values and print the output.

float f(float feet,float yard)
float miles;
feet = 3 * yard + feet ;
miles = feet / 5280.0;
return miles;
int main()
float feet,yard;
printf("\nEnter total Yards: ");
scanf("%f", &yard);
printf("Enter total Feets: ");
scanf("%f", &feet);
printf("\nFeet = %.2f , Yard = %.2f \nEquivalent Miles = %.2f\n",feet,yard,f(feet,yard));
return 0;

For more programs in C, visit our C Coder Archives

Convert Yard and Feet to Miles coderinme

All rights reserved. No part of this Post may be copied, distributed, or transmitted in any form or by any means, without the prior written permission of the website admin, except in the case of brief quotations embodied in critical reviews and certain other noncommercial uses permitted by copyright law. For permission requests, write to the owner, addressed “Attention: Permissions Coordinator,” to the admin @coderinme

Leave a reply:

Your email address will not be published.