Complete the code to correctly add 3 and 4, then multiply by 2.
int result = (3 + 4) [1] 2; Console.WriteLine(result);
The multiplication operator (*) has higher precedence than addition, but parentheses force addition first. So (3 + 4) * 2 = 14.
Complete the code to check if 5 is greater than 3 and less than 10.
bool check = 5 [1] 3 && 5 < 10; Console.WriteLine(check);
The expression 5 > 3 checks if 5 is greater than 3, which is true. Combined with 5 < 10, the whole expression is true.
Fix the error in the expression to correctly compute the value.
int value = 10 + 5 [1] 2; Console.WriteLine(value);
Multiplication (*) has higher precedence than addition, so 5 * 2 is calculated first, then added to 10, resulting in 20.
Fill both blanks to create a dictionary with word lengths for words longer than 3 characters.
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}");The filter keeps words with length greater than 3. Then it adds 1 to each length in the new dictionary.
Fill all three blanks to create a dictionary with uppercase keys and values greater than 0.
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}");The filter keeps entries with Value > 0. The keys are converted to uppercase using ToUpper(), and the values are kept as Value.