Today I'm going to provide you the program of unit conversion in C programming language...
#include <stdio.h>
int main()
{
char input;
float kmsTomiles = 0.621371;
float inchesTofoot = 0.083333;
float cmsTOinches = 0.393701;
float poundTokgs = 0.453592;
float inchesTometers = 0.621371;
float newtonToerg = 10000000;
float first, second;
while (1)
{
printf("Enter the input character. q to quite\n 1. kms to miles\n 2. cms to inches\n 3. pound to kgs\n 4. inches to foot\n 5. inches to meters\n");
scanf(" %c", &input);
switch (input)
{
case 'q':
printf("Quiting the program...");
goto end;
break;
case '1':
printf("Enter quntity 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 quntity 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 quntity 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 quntity 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 quntity in terms of first unit\n");
scanf("%f", &first);
second = first * inchesTometers;
printf("%f inches is equal to %f meters\n", first, second);
break;
case '6':
printf("Enter quntity in terms of first unit\n");
scanf("%f", &first);
second = first *newtonToerg ;
printf("%f newton is equal to %f erg\n", first, second);
break;
default:
break;
}
}
end:
return 0;
}
Comments
Post a Comment