Decimal Places/Conversion


I have to write a program where centimeters is converted to feet and inches. For example, the input is 333.3 cm, the output should be 10 ft and 11.2 inches. I already have written the program as follow;

#include <stdio.h>
#include <stdlib.h>
#define In 2.54
#define Ft 12

void main ()

int a;
float X;
printf ("\nEnter the value to be converted: ");
scanf ("%d", &a);
printf ("The area: %5.2f\n", X);
getch ();


The result I got for 333.3 cm is 10.93. My question is how to convert that 0.93 to 11.2 inches. Any response will be truly appreciated. Thank you!

0.93 * numberOfInchesInAFoot
I mean the output should be 10 ft 11.2 inches. So if I input another number the result should be in that format.. in ___ ft ____ inches. Thank you.
You're using C funtions, is that intentional?

Take a look at fmod() and modf() in the math.h library

you'll need another variable to store the inches
Last edited on
Thank you! Will try what you suggested. Thanks
Topic archived. No new replies allowed.