i need some help plz

Status
Not open for further replies.
I don't know what its talking about with that error. You're going to have to copy and paste your exact code and then copy and paste the exact error because I have no idea what its talking about.

Although I suspect that the problem you're having lies elsewhere.
 
/* This program converts height in centimeters and
displays it into height in centimeters, feet, inches.*/


#include<stdio.h>
#include<math.h>
const double FEET_PER_CENTIMETER=0.033;
const double INCHES_PER_CENTIMETER=0.4;
const double CENTIMETERS_PER_FOOT=1.0/FEET_PER_CENTIMETER;
int main(void) {

int cent, centf, centi;

printf("COnvert Height Into Feet & Inches!\n");
printf("Please Enter Your Height In Centimeters: (<=0 to quit\n");
scanf("%d", &cent);
while (cent>0)
{
centf=(int)(cent*FEET_PER_CENTIMETER);
centi=(int)((cent-floor(centf*CENTIMETERS_PER_FOOT))*INCHES_PER_CENTIMETER);
printf("%d cm= %d feet, %d inches\n", cent, centf, centi);
printf("Enter Another Height to COntinue: (<=0 to quit)\n");
scanf("%d", &cent);
}
printf("BYE!\n");
return 0;
}
/*----------------------------------------------------------------------*/
 
Wheres the error message?

It may not like that logic with the math on the constant. Try just using CENTIMETERS_PER_FOOT=30.3;
 
sngm0375@munro question4]$ gcc Height.c -o height
/tmp/ccq2PU8I.o(.text+0x88): In function `main':
: undefined reference to `floor'
collect2: ld returned 1 exit status"

thats the error sory i was excited to try it out....yea i changed it to 30.3 and it gave me the error above..
 
#include<stdio.h>
#include<math.h>
const double FEET_PER_CENTIMETER=0.033;
const double INCHES_PER_CENTIMETER=0.4;
const double CENTIMETERS_PER_FOOT=30.3;
int main(void) {

int cent, centf, centi;

printf("COnvert Height Into Feet & Inches!\n");
printf("Please Enter Your Height In Centimeters: (<=0 to quit\n");
scanf("%d", &cent);
while (cent>0)
{
centf=(int)(cent*FEET_PER_CENTIMETER); /*you said it dont mind if i use the (int) right so i used it for this lien and the next line but then the floor is still in the third line from here and its referenceing to that one ..
centi=(int)((cent-floor(centf*CENTIMETERS_PER_FOOT))*INCHES_PER_CENTIMETER);
printf("%d cm= %d feet, %d inches\n", cent, centf, centi);
printf("Enter Another Height to COntinue: (<=0 to quit)\n");
scanf("%d", &cent);
}
printf("BYE!\n");
return 0;
}
/*----------------------------------------------------------------------*/
 
i was thinking bout if like in that long line with all the operations going on if it can possibly be split so that one line can calculate the remainder and one line for the conversion to inches i dunno if that is possible and then floor wont hav to be used just a suggesion
 
Status
Not open for further replies.
Back
Top Bottom