C# Programming - Operators - Discussion

Discussion Forum : Operators - General Questions (Q.No. 18)
18.
Which of the following statements are correct about the following code snippet?
int a = 10; 
int b = 20;
bool c;
c = !(a > b);
  1. There is no error in the code snippet.
  2. An error will be reported since ! can work only with an int.
  3. A value 1 will be assigned to c.
  4. A value True will be assigned to c.
  5. A value False will be assigned to c.
1, 3
2, 4
4, 5
1, 4
None of these
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
5 comments Page 1 of 1.

Prashant kumar sharma said:   1 decade ago
On solving bracket we have false value and then not operator so it invert the value. It become true.

And 4th option also correct.

Robert said:   1 decade ago
Bool means true or false c is declared as bool, So the value return true not 1, if c declared int then the value return 1.

Bhavin Umaraniya said:   1 decade ago
In bracket condition is false when applied with NOT operator (!) it will become TRUE.

Namrata said:   1 decade ago
When the value will be one and when the value will be True ?

Shiv said:   9 years ago
True will be assigned to C.

Post your comments here:

Your comments will be displayed after verification.