In this example we are going to convert km to miles using C program. In program first we take input from user in KM then we will convert it into Miles using Bellow formula.
1 km = 0.621 miles
Convert km to miles using C program
#include<stdio.h>
void main()
{
float km, miles;
printf("Enter any values in km : ");
scanf("%d",&km);
miles = km * 0.621;
printf("%.2f kilometer is = %.2f miles",km,miles);
}
Output
Enter any values in km : 15
15.00 km is = 9.32 miles
Explanation
In this program we have taken a input from user in KM then we converted it into mile using the formula hence we display the result.
Introduction of C and Hello World Program
C program to Addition of two numbers
C program to find Area of Triangle
C program to find Area of Circle
C program to find Area of Rectangle
C program to Calculate Simple Interest
C program to Calculate Compound Interest
C program to Find Percentage of 5 Subjects