unit conversion used if

 #include <stdio.h>


int main(void)

{

int select;

    printf("Enter 1 from kms to mile\n Enter 2 for inches to feets\n Enter 3 for cms to inches\n Enter 4 for pounds to kg\n Enter 5 for inches to meter\n");

    scanf("%d",&select);

    printf("you selected %d\n",select);

    if(select==1){

    float km,ans;

    scanf("%f", &km);

    printf("Enter kms to change in miles%f\n",km);

    ans=0.621*km;

    printf("%f is your miles\n",ans);

    }

    else if(select==2){

    float inches,ans;

    scanf("%f",&inches);

    printf("Enter inches to change in feets%f\n",inches);

    ans=0.0833*inches;

    printf("%f is your feets\n",ans);

    }

    else if(select==3){

    float cms,ans;

    scanf("%f",&cms);

    printf("Enter cms to change in inches%f\n",cms);

    ans=0.394*cms;

    printf("%f is your inches\n",ans);

    }

    else if(select==4){

    float pounds,ans;

    scanf("%f", &pounds);

    printf("Enter pounds to change in kg%f\n",pounds);

    ans=0.454*pounds;

    printf("%f is your pounds\n",ans);

    }

    else if(select==5){

    float inches,ans;

    scanf("%f", &inches);

    printf("Enter inches to change in meter%f\n",inches);

    ans=0.0254*inches;

    printf("%f is your miles\n",ans);

    }

    else{

    printf("invalid input \n");

    }

}


Comments