-
cout<<"Error";
why does
print 2 not 2.98?
-
Programming Sex-God
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;
or
cout << 149.0/50;
or
cout << (float)149/50;
or
cout << (double)149/50;
will give you 2.98
(Anything that will tell the compiler to convert the result to a floating point type.)
-
-
*meep*
thanks whoever posted first :-p
Last edited by krappykoder; 03-01-2003 at 07:41 AM.
Popular pages
Recent additions