is it possible to calculate a ratio using a function in C?? or do i have to do up a formula??
+2
A:
float ratio (float a, float b){
return a/b;
}
You might be having a problem with the following:
int a=5;
int b=4;
float ratio=b/a; // yields 1.0000 since it is interpreted as integer division
float ratioCorrect=(float)b/a; // yields 1.25 because yuo told the compiler to interpret numbers as floats
phimuemue
2010-10-29 06:12:28
thanks for answering the poor guy's question.
Kaustubh P
2010-10-29 07:31:06