The boolean data type in C++?
When i assign a non-zero value to a boolean variable, the output is true. And when i assign a non-zero value from the console, the output is false.
WHY?
Please take a look at the following codes:
#include <iostream.h>
#include <conio.h>
main()
{
bool bln;
cout<<"Enter value: ";
cin>>bln;
if (bln==true)
{
cout<<bln<<"TRUE";
}
else
{
cout<<bln<<"FALSE";
}
getch();
}
Output:
0FALSE
/*************************************...
#include <iostream.h>
#include <conio.h>
main()
{
bool bln=253;
if (bln==true)
{
cout<<bln<<"TRUE";
}
else
{
cout<<bln<<"FALSE";
}
getch();
}
Output:
1TRUE
MAXOOD!
Life is an endless journey towards perfection
__________________
MAXOOD!
Life is an endless journey towards perfection
|