#include <iostream>
using namespace std;
int main (void) {
float a=5/9;
cout << a;
}
This code prints 0 and not 0.555 - what is the problem? Any help appreciated.
#include <iostream>
using namespace std;
int main (void) {
float a=5/9;
cout << a;
}
This code prints 0 and not 0.555 - what is the problem? Any help appreciated.
5/9
is a division of two integers and its result is 0
. If you want the operation done in float
s then at least one operand has to be a float
:
5/9.f