Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to print the name using composite formatting.
C Sharp (C#)
string name = "Alice"; Console.WriteLine("Hello, [1]!", name);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the variable name inside the string without braces.
Using empty braces {} which is invalid in C# composite formatting.
✗ Incorrect
Composite formatting uses placeholders like {0} to insert values.
2fill in blank
mediumComplete the code to print the age using composite formatting.
C Sharp (C#)
int age = 30; Console.WriteLine("Age: [1]", age);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using {1} when there is only one argument.
Using variable names inside braces which is not supported in composite formatting.
✗ Incorrect
The placeholder {0} refers to the first argument after the format string.
3fill in blank
hardFix the error in the composite formatting to print both name and age.
C Sharp (C#)
string name = "Bob"; int age = 25; Console.WriteLine("Name: [1], Age: {1}", name, age);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable names inside braces instead of numbers.
Using {2} when only two arguments are provided.
✗ Incorrect
Use {0} for the first argument and {1} for the second argument in composite formatting.
4fill in blank
hardFill both blanks to format a floating number with 2 decimal places and align it right in 10 spaces.
C Sharp (C#)
double price = 123.456; Console.WriteLine("Price: [1], Total: [2]", price, price * 2);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong indexes for placeholders.
Omitting alignment or format specifier.
✗ Incorrect
Use {index,width:format} to align and format numbers. {0,10:F2} means first argument, right aligned in 10 spaces with 2 decimals.
5fill in blank
hardFill all three blanks to print a formatted string with name uppercase, age, and balance with currency format.
C Sharp (C#)
string name = "Carol"; int age = 40; double balance = 1234.5; Console.WriteLine("Name: [1], Age: [2], Balance: [3]", name.ToUpper(), age, balance);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up argument indexes.
Forgetting the currency format specifier.
✗ Incorrect
Use {0} for first argument (name uppercase), {1} for age, and {2:C} to format balance as currency.