+ 1
How to write the output when the cout statement has == eg.cout<< ans==8
4 Answers
+ 3
Using double Equal to- sign is basically a Comparator operator.
For every two compared parameters, it either generates a "True" or a "False" statement.
The following example will show you the idea of how to use "==" in a cout statement:-
void main()
{
int number;
cout<<"Enter the number ";endl;
cin>>number;
cout<<( number==8? " True":"False");
return 0;
}
+ 1
You want to print true or false instead of 1 or 0, correct?
cout << (ans==8? "true" : "false");
+ 1
Use parentheses - ( and ) - around things that belong together, so:
cout << (ans ==8);
+ 1
cout<<"ans==8";