Unit Conversion By The Help Of C Programming || Program of unit conversion in C language ||

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 firstsecond;

    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"firstsecond);
            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"firstsecond);
            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"firstsecond);
            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"firstsecond);
            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"firstsecond);
            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"firstsecond);
            break;

        default:
            break;
        }
    }
end:
    return 0;
}

Comments