Unknown behavior of the C++ problem

#include
using namespace std;

int main()
{

double a;

cin >> a;

a=a-(int)a;

a=a*10000;

cout << (int)a;

return 0;

}

when i input 1.1500
then i get input 1499 but the output should be 1500

There is loss of precision associated when you typecast a double/float to int.
In the last step again , you have typecasted it to int where this loss is occuring

cout<<a<<endl;

instead of

cout<<(int)a<<endl;

will give you 1500.

loss of precision associated…
instead of

cout << (int)a;

use

cout << a;
or
cout << (float)a;

it will give u 1500

//