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

Logical patterns (and, or, not) 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||
Bor
C|
D&&
Attempts:
3 left
💡 Hint
Common Mistakes
Using || instead of &&
Using single & which is a bitwise operator
2fill in blank
medium

Complete the code to check if either 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&&
Dand
Attempts:
3 left
💡 Hint
Common Mistakes
Using && instead of ||
Using single & which is a bitwise operator
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!
Bnot
C~
Dnegate
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'not' keyword which is not valid in C#
Using bitwise complement operator ~ which is for integers
4fill in blank
hard

Fill all three blanks to check if number is between 10 and 20 inclusive.

C Sharp (C#)
bool inRange = (num [1] 10) [2] (num [3] 20);
Drag options to blanks, or click blank then click option'
A>=
B&&
C<=
D||
Attempts:
3 left
💡 Hint
Common Mistakes
Using || instead of && which allows numbers outside the range
Using > or < instead of >= or <=
5fill in blank
hard

Fill all three blanks to check if a character is a vowel (a, e, i, o, u).

C Sharp (C#)
bool isVowel = (ch == 'a') [1] (ch == 'e') [2] (ch == 'i') [3] (ch == 'o') || (ch == 'u');
Drag options to blanks, or click blank then click option'
A||
B&&
Attempts:
3 left
💡 Hint
Common Mistakes
Using && which requires all conditions to be true (impossible here)
Mixing && and || operators incorrectly