Solved

# math calculations

Posted on 1999-01-28

i am having trouble getting an int divide with another value and answer in 2 decimal places. here's the problem:

the user answered "05:04" as time so:

char ans[5]="05:04";

i need to convert the min=.04 to .07 of 60 mins (the fraction within the 60 min whole).

so the answer = "05.07"

now, i tried the following and it keeps giving me a 0 for an answer. please help.

/*-------------------------*/

char ans[5]="05:04";

float value=0.0;

int h,m;

sscanf(ans,"%2d:%2d",&h,&m);

value= h;

if(m >=0 && m < 60)

value= (value+(m/60));

/*----------------------------------------*/

the real problem is when i calculate (m/60), i get an answer of .0000000 instead of .066, HOW DO I GET AN ANSWER WITH 2 DECIMAL PLACES?

zandy1