+ 1

How to write the output when the cout statement has == eg.cout<< ans==8

25th Oct 2016, 5:55 AM
Diksha Gautam
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; }
25th Oct 2016, 9:49 AM
Shubham Jaydeokar
+ 1
You want to print true or false instead of 1 or 0, correct? cout << (ans==8? "true" : "false");
25th Oct 2016, 9:02 AM
Zen
Zen - avatar
+ 1
Use parentheses - ( and ) - around things that belong together, so: cout << (ans ==8);
27th Oct 2016, 4:27 AM
Rhydian Davies
+ 1
cout<<"ans==8";
30th Oct 2016, 5:17 AM
Dheeraj Garg
Dheeraj Garg - avatar