Tuesday, August 27, 2013

Length or Distance Conversion using Turbo C

Sample Output
#include<stdio.h>
#include<conio.h>
//this simple program is a convertion of Lenght or Distance using do case

int main()
{
 char ch;
 float mm, cmtr, cm, ft, feet, inc, inch;

           printf ("\n\n-Convertion of Length-Distance-\n");
           printf("1.Millimeter?\n");
           printf("2.Centimeter?\n");
           printf("3.Inches?\n");
           printf("4.Foot?\n");
           printf("Enter you choice:");
         do{
          ch=getche();
          switch(ch){
             case '1':
                 printf("\n\n Input Millimeter?");scanf("%f",&mm);
                 cmtr= mm * 0.1; // millimeter to centimetr
                 inch= mm * 0.0393701; // millimeter to inch
                 ft= mm * 0.00328084; // millimeter to foot or feet
                 printf("Centimeter =>%.6f\n",cmtr);
                 printf("Inches  =>%.6f\n",inch);
                 printf("Foot  =>%.6f\n", ft);   
                 break;
            case '2':
                 printf("\n\n Input Centimeter?");scanf("%f",&cm);
                 inch= cm * 0.393701; //centimeter to inch
                 mm= cm * 10; //centimeter to millimeter
                 ft= cm * 0.0328084; //centimeter to foot or feet
                 printf("Inches  =>%.10f\n",inch);
                 printf("Mellimeter =>%.10f\n",mm);
                 printf("Foot  =>%.10f\n", ft);
                 break;              
            case '3':
                 printf("\n\n Input Inches?");scanf("%f",&inch);
                 mm= inch * 25.4; // inch to millimeter
                 ft= inch * 0.0833333; //inch to foot or feet
                 cm= inch * 2.54; //inch to centimeter
                 printf("Mellimeter =>%.8f\n",mm);
                 printf("Foot  =>%.8f\n", ft);
                 printf("Centimeter  =>%.8f\n",cm);    
                 break;
            case '4':
                 printf("\n\n Input Foot?");scanf("%f",&ft);
                 cm= ft * 30.48; //feet to centimeter
                 inch= ft * 12; //feet to inch
                 mm= ft * 304.8; // feet to millimeter
                 printf("Centimeter =>%.8f\n",cm);
                 printf("Inches =>%.8f\n",inch);
                 printf("Millimeter =>%.8f\n", mm);     
                 break;
                 }  
           }while(ch!='1' && ch!='2' && ch!='3' && ch!='4');
getche();

}

//created by: boybalda46
//