#include<iostream>
using
namespace
std;
int
main()
{
if
(!(cout <<
"abc"
))
cout <<
" abc "
;
else
cout <<
"def"
;
return
0;
}
#include<iostream>
using
namespace
std;
int
main()
{
if
(!(cout <<
"abc"
))
cout <<
" abc "
;
else
cout <<
"def"
;
return
0;
}
output will be : abcdef
cout << "abc"
which returns a non-zero value,
!(non-zero value) is false,
hence it executes else .
Hence technically it only executes else block
The program will return the following output :
abcdef
This will be the output because the first cout in the if the condition will give you the output ‘abc’ and return a non zero value with, will negate to a negative one. This runs the else condition and the ‘def’ will be returned to the output screen.