glitter boy wrote:

Ok so I have this class for C. I have to write this program for my

instructor, where he has already posted the softcopy and algorithm. But

my question is I have to convert meters to feet and in this I have to

output not only the feet but also the inches now I think I have coded

the feet calculation properly but. I don't know how to send the

remainder to inches and than recalculate it and display that

calculation here is what I have coded this so far.

[...] float HM /*hight in meters*/

float INCHES /*hight in inches (later adjust to just inches of

height)*/

float FEET /*whole feet portion of height*/

leaving off those semicolons will kill you. It is conventional to use

all uppercase only in naming macros.

Try seeing if you can tell what's happening here:

#include <stdio.h>

#include <math.h>

#define FACTOR 2.54

int main(void)

{

double height_in_meters;

double inch_portion_of_height;

double foot_portion_of_height;

printf("Height Convertion Program\n"

"Designed by Randolph Gibson - 15 january 2001\n"

"Coded by Rome Baker - September 2005\n\n"

"This program will convert a person's height from meters\n"

"into feet and inches (rounded to the nearest inch) and \n"

"display the result on the screen. The height must be\n"

"entered in metric units and contain decimal portions.\n"

"The answer will be displayed in whole feet and "

"inches.\n\n");

do {

printf("Enter the person's height in meters: ");

fflush(stdout);

scanf("%lf", &height_in_meters);

if (height_in_meters <= 0)

printf("We deal only in people with heights > 0.\n");

} while (height_in_meters <= 0);

inch_portion_of_height = height_in_meters * 100 / FACTOR;

foot_portion_of_height = floor(inch_portion_of_height / 12);

inch_portion_of_height -= 12 * foot_portion_of_height;

printf("\nThe height is equivilant to %.0f'%.0f\".\n",

foot_portion_of_height, inch_portion_of_height);

return 0;

}