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

Why operators matter in C Sharp (C#) - Test Your Understanding

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

Complete the code to add two numbers and print the result.

C Sharp (C#)
int a = 5;
int b = 3;
int sum = a [1] b;
Console.WriteLine(sum);
Drag options to blanks, or click blank then click option'
A+
B-
C*
D/
Attempts:
3 left
💡 Hint
Common Mistakes
Using subtraction instead of addition.
Using multiplication or division by mistake.
2fill in blank
medium

Complete the code to check if a number is greater than 10.

C Sharp (C#)
int number = 15;
if (number [1] 10)
{
    Console.WriteLine("Greater than 10");
}
Drag options to blanks, or click blank then click option'
A<=
B==
C<
D>
Attempts:
3 left
💡 Hint
Common Mistakes
Using less than operator instead.
Using equality operator instead of comparison.
3fill in blank
hard

Fix the error in the code to multiply two numbers.

C Sharp (C#)
int x = 4;
int y = 6;
int product = x [1] y;
Console.WriteLine(product);
Drag options to blanks, or click blank then click option'
A/
B*
C+
D-
Attempts:
3 left
💡 Hint
Common Mistakes
Using addition or subtraction instead of multiplication.
Using division operator by mistake.
4fill in blank
hard

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

C Sharp (C#)
var words = new List<string> { "apple", "cat", "banana", "dog" };
var lengths = words.Where(word => word.Length [1] 3)
                   .ToDictionary(word => word, word => word.Length [2] 1);
Drag options to blanks, or click blank then click option'
A>
B<
C+
D-
Attempts:
3 left
💡 Hint
Common Mistakes
Using less than operator for filtering.
Adding instead of subtracting in the dictionary value.
5fill in blank
hard

Fill all three blanks to create a dictionary with uppercase keys and their lengths for words with length greater than 4.

C Sharp (C#)
var words = new List<string> { "tree", "house", "car", "elephant" };
var result = words.Where(w => w.Length [1] 4)
                  .ToDictionary(w => w.[2](), w => w.Length [3] 0);
Drag options to blanks, or click blank then click option'
A>
BLength
C+
DToUpper
Attempts:
3 left
💡 Hint
Common Mistakes
Using less than operator for filtering.
Using property name instead of method call for uppercase.
Using subtraction instead of addition in length calculation.