I am initializing a variable a of type float with value 1.2.
If I print it on screen, it give me 1.2, but when I check it with if/else, it does not run the if statement whose condition is if(a == 1.2). Instead it runs the else part.
Can someone please help, I am still learning the basics.
Here is my code:
#include<iostream>
#include<iomanip>
using namespace std;
int main ()
{
float a = 1.2;
cout<<fixed<<setprecision(1)<<a<<endl;
if (a == 1.2)
cout<<"\n a is 1.2";
else
cout<<"\n a is not 1.2";
return 0;
}