0
0
C Sharp (C#)programming~10 mins

Logical operators in C Sharp (C#) - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to check if both conditions are true.

C Sharp (C#)
bool result = (a > 5) [1] (b < 10);
Drag options to blanks, or click blank then click option'
A^
B||
C|
D&&
Attempts:
3 left
💡 Hint
Common Mistakes
Using || instead of && causes the condition to be true if either side is true.
2fill in blank
medium

Complete the code to check if at least one condition is true.

C Sharp (C#)
bool result = (x == 0) [1] (y == 1);
Drag options to blanks, or click blank then click option'
A||
B^
C&
D&&
Attempts:
3 left
💡 Hint
Common Mistakes
Using && instead of || causes the condition to require both sides true.
3fill in blank
hard

Fix the error in the code to negate the condition.

C Sharp (C#)
bool isFalse = [1](flag);
Drag options to blanks, or click blank then click option'
A!
Bflag
C!!
Dnot
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'not' keyword which is not valid in C#.
Using double exclamation marks (!!) which is invalid syntax.
4fill in blank
hard

Fill both blanks to create a condition that is true only if a is true and b is false.

C Sharp (C#)
bool result = (a [1] true) [2] (b [3] false);
Drag options to blanks, or click blank then click option'
A==
B&&
C||
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using || instead of && changes the logic to 'or' instead of 'and'.
Using != instead of == for comparisons causes wrong results.
5fill in blank
hard

Fill all three blanks to create a condition that is true if x is greater than 10 or y is less than 5 and z is not equal to 0.

C Sharp (C#)
bool check = (x [1] 10) [2] (y [3] 5) && (z != 0);
Drag options to blanks, or click blank then click option'
A>
B<
D||
Attempts:
3 left
💡 Hint
Common Mistakes
Using && instead of || changes the logic to require both conditions true.
Using >= or <= instead of > or < changes the condition meaning.