print 2 not 2.98?
because 149 and 50 are both integers, so the result of the division is an integer.
You have to use floating point types to get the right answer. Do 149.f/50.f instead.
cout << 149./50;
cout << 149.0/50;
cout << (float)149/50;
cout << (double)149/50;
will give you 2.98
(Anything that will tell the compiler to convert the result to a floating point type.)
thanks whoever posted first :-p
Last edited by krappykoder; 03-01-2003 at 06:41 AM.