Wednesday, 10 September 2014

C Language Program for converting centimeters to feet and inches with Example


C program - Conversion of centimeters to feet and inches. This sample  & simple program discuss about converting CM to feet & inches by using the C source code. It can be used in all LAB exams and theory exams also. It is an useful C program for beginners.

CENTIMETER TO FEET AND INCHES IN C

Convert centimeters to feet and inches in C. It is used to convert the getting centimeter value into inch by dividing the centimeter with inches and getting the feet value by inch divided by foot. And finally get the variable value by (inch-(feets*foot)).


//Header files
#include
#include
#define INCHES 2.54
#define FOOT 12
 
void main()
{
 
    clrscr(); //Function is used to clear previous output
    //Program variables
    float cm,inch,a;
    int feets;
 
    printf("Enter value of centimeter: "); //Display function
    scanf("%f",&cm); //Getting input value function
 
    // This method will convert centimeter to feet and inches
    inch = cm/INCHES;
    feets = inch/FOOT;
    a = inch-(feets*FOOT);
 
    printf("%d Feet and %.1f inches",feets,a);
    getch();
}

No comments:

Post a Comment

Note: only a member of this blog may post a comment.