Pages

Thursday, October 21, 2010

CONVERTION

The unit foot is usually used to measured heights. There are other units that are used for appropriate lengths inches which are used to measure margins, meters to measure lot areas, yards to code the C program to input a length in feet and experience/convert this length in to inches, meters, centimeters, yards, and fathom. Use the conversion factors given below.
1 foot = 12 inches
1 inch = 2.54 centimeters
1yrad = 3 feet
1 meter = 100 centimeters
1 fathom = 6 feet


#include<stdio.h>
#include<conio.h>

int main(void)
{
    float ft, inch, m, cm, yards, fathom;

    clrscr();
    printf("\n\t\tEnter a length in feet:");
    scanf("%f",&ft);

    inch =ft*12;
    cm =ft*12*2.54;
    m =(ft*12*2.54)/100;
    yards =ft/3;
    fathom =ft/6;

    printf("\n\n\t\t%.2f feet = %.2f inches",ft,inch);
    printf("\n\n\t\t%.2f feet = %.2f centimeters",ft,cm);
    printf("\n\n\t\t%.2f feet = %.2f yards",ft,yards);
    printf("\n\n\t\t%.2f feet = %.2f meters",ft,m);
    printf("\n\n\t\t%.2f feet = %.2f fathoms",ft,fathom);
    getch();
}

No comments:

Post a Comment