I tried the following code :
#include <iostream>
#include<conio.h>
using namespace std;
int main()
{
int intvar = 25;
float floatvar = 35.87;
cout << "intvar= " << intvar;
cout << "\n floatvar =" << floatvar;
cout << "\n float(intvar)=" << float(intvar);
cout << "\n int(floatvar)=" << int(floatvar);
_getch();
return 0;
}
The result for float(intvar)
is coming as 25
.
Can someone please explain why it is still being shown as an integer and not 25.000000
?