C Program to Convert Yard to Feet

In this post, we will learn how to convert yard to feet using C Programming language.

We know 1 Yard = 3 Feet, so we will be using this data in our program to convert yard to feet.

So, without further ado, let’s begin this tutorial.

C Program to Convert Yard to Feet

// C Program to Convert Yard to Feet
#include <stdio.h>
int main(){
    float yard, feet;
    
    // Asking for input
    printf("Enter the length in yards: ");
    scanf("%f", &yard);
    
    // Yard to feet
    feet = 3 * yard;
    
    // Display output
    printf("%.2f Yards = %.2f Feet", yard, feet);
    return 0;
}

Output

Enter the length in yards: 15
15.00 Yards = 45.00 Feet

How Does This Program Work ?

    float yard, feet;

In this program we have declared two float data type variables named yard and feet.

    // Asking for input
    printf("Enter the length in yards: ");
    scanf("%f", &yard);

Then, the user is asked to enter the length in yards.

    // Yard to feet
    feet = 3 * yard;

We convert the length from yards to feet by multiplying the length by 3.

    // Display output
    printf("%.2f Yards = %.2f Feet", yard, feet);

Finally, the output is printed on the screen using printf() function.

Conclusion

I hope after going through this post, you understand how to convert yard to feet using C Programming language.

If you have any doubt regarding the program, feel free to contact us in the comment section. We will be delighted to solve your query.

Also Read:

Leave a Comment

Your email address will not be published.