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

Operator precedence and evaluation order 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 correctly add 3 and 4, then multiply by 2.

C Sharp (C#)
int result = (3 + 4) [1] 2;
Console.WriteLine(result);
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 result to be 9 instead of 14.
2fill in blank
medium

Complete the code to check if 5 is greater than 3 and less than 10.

C Sharp (C#)
bool check = 5 [1] 3 && 5 < 10;
Console.WriteLine(check);
Drag options to blanks, or click blank then click option'
A>
B<
C==
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using < instead of > reverses the logic and results in false.
3fill in blank
hard

Fix the error in the expression to correctly compute the value.

C Sharp (C#)
int value = 10 + 5 [1] 2;
Console.WriteLine(value);
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 result to be 17 instead of 20.
4fill in blank
hard

Fill both blanks to create a dictionary with word lengths for words longer than 3 characters.

C Sharp (C#)
var lengths = new Dictionary<string, int> {
    {"apple", "apple".Length},
    {"bat", "bat".Length}
};
var filtered = lengths.Where(kv => kv.Value [1] 3).ToDictionary(kv => kv.Key, kv => kv.Value [2] 1);
foreach(var item in filtered) Console.WriteLine($"{item.Key}: {item.Value}");
Drag options to blanks, or click blank then click option'
A>
B+
C-
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using < instead of > filters wrong words.
Using - instead of + decreases lengths incorrectly.
5fill in blank
hard

Fill all three blanks to create a dictionary with uppercase keys and values greater than 0.

C Sharp (C#)
var data = new Dictionary<string, int> { {"a", 1}, {"b", 0}, {"c", 3} };
var result = data.Where(kv => kv.Value [1] 0).ToDictionary(kv => kv.Key.[2](), kv => kv.[3]);
foreach(var item in result) Console.WriteLine($"{item.Key}: {item.Value}");
Drag options to blanks, or click blank then click option'
A==
BValue
C>
DToUpper
Attempts:
3 left
💡 Hint
Common Mistakes
Using == filters only values equal to zero.
Using Key instead of Value for values causes errors.