if the input is for example 1 the out put hsould 1 and in case the in put is 1,2 the function should return 2!! not 1!
This may or may not be the cause of your trouble, but you should never use '==' for doubles. Due to floating point error, equality will almost never happen. Whenever you want to compare doubles, you need to do something like this:
-
if( fabs( a - b ) < eps )
-
{
-
// do something ...
-
}
-
where eps is something small, like 1e-8.
As for your test case, do you mean to test "myCeil(1.2) = 2"? I'm afraid that with the syntax of your sentence, I'm not sure if the "comma" is punctuation or a European decimal point. ;)
Lastly, I'm a little bit concerned about your function. It seems to me (and again, I may be misreading it) that you are assuming that the integer cast will always return the integer part of the number (i.e., is acting almost like a floor function). I'm not sure how entirely safe it is to assume that a compiler will cast a double to an integer in a certain way. You might want to consider using "modf" instead.
BTW, why aren't you using the built-in "ceil" function? I can understand not using the horrible built-in "rand" and "round" functions, but as I've seen, ceil works quite fine.
Thanks -- Paul