C Program to convert Kms to Miles, Inches to foot, cms to Inches, Pound to Kgs, Inches to Metre
include <stdio.h>
int main()
{
char input;
float KmsToMiles = 0.621371;
float inchesToFoot = 0.0833333;
float cmsToInches = 0.393701;
float poundToKgs = 0.453592;
float inchesToMetres = 0.0254;
float first, second;
while (1)
{
printf("Enter the input character. q to quit\n 1. kms To miles\n 2. inches to foot\n 3. cms to inches\n 4. pound to kgs\n 5. inches to metre\n");
scanf(" %c", &input);
switch (input)
{
case 'q':
printf("Quiting the program....");
goto end;
break;
case '1':
printf("Enter quantity in terms of first unit\n");
scanf("%f", &first);
second = first * KmsToMiles;
printf("%f Kms is equal to %f Miles\n", first, second);
break;
case '2':
printf("Enter quantity in terms of first unit\n");
scanf("%f", &first);
second = first * inchesToFoot;
printf("%f Inches is equal to %f Foot\n", first, second);
break;
case '3':
printf("Enter quantity in terms of first unit\n");
scanf("%f", &first);
second = first * cmsToInches;
printf("%f Cms is equal to %f Inches\n", first, second);
break;
case 4:
printf("Enter quantity in terms of first unit\n");
scanf("%f", &first);
second = first * poundToKgs;
printf("%f pound is equal to %f Kgs\n", first, second);
break;
case '5':
printf("Enter quantity in terms of first unit\n");
scanf("%f", &first);
second = first * inchesToFoot;
printf("%f Inches is equal to %f Metre\n", first, second);
break;
default:
break;
}
}
end:
return 0;
OUTPUT:
Enter the input character. q to quit
1. kms To miles
2. inches to foot
3. cms to inches
4. pound to kgs
5. inches to metre
3
Enter quantity in terms of first unit
67
67.000000 Cms is equal to 26.377966 Inches
Enter the input character. q to quit
1. kms To miles
2. inches to foot
3. cms to inches
4. pound to kgs
5. inches to metre
2
Enter quantity in terms of first unit
1000
1000.000000 Inches is equal to 83.333298 Foot
Enter the input character. q to quit
1. kms To miles
2. inches to foot
3. cms to inches
4. pound to kgs
5. inches to metre
4
Enter the input character. q to quit
1. kms To miles
2. inches to foot
3. cms to inches
4. pound to kgs
5. inches to metre
654
Enter the input character. q to quit
1. kms To miles
2. inches to foot
3. cms to inches
4. pound to kgs
5. inches to metre
Enter quantity in terms of first unit
4.000000 Inches is equal to 0.333333 Metre
Enter the input character. q to quit
1. kms To miles
2. inches to foot
3. cms to inches
4. pound to kgs
5. inches to metre
5
Enter quantity in terms of first unit
789
789.000000 Inches is equal to 65.749969 Metre
Enter the input character. q to quit
1. kms To miles
2. inches to foot
3. cms to inches
4. pound to kgs
5. inches to metre
1
Enter quantity in terms of first unit
567
567.000000 Kms is equal to 352.317352 Miles
Enter the input character. q to quit
1. kms To miles
2. inches to foot
3. cms to inches
4. pound to kgs
5. inches to metre
q
Quiting the program....
PS C:\Users\hp\C Tutorials course>
}
Tysm
ReplyDelete