Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to print "Hello, World!" in C#.
C Sharp (C#)
using System; class Program { static void Main() { Console.[1]("Hello, World!"); } }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using methods like Print or Display which do not exist in C# Console class.
✗ Incorrect
In C#, Console.WriteLine prints text to the screen with a new line.
2fill in blank
mediumComplete the code to declare an integer variable named 'age' with value 25.
C Sharp (C#)
int [1] = 25;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using generic names like number or value instead of 'age'.
✗ Incorrect
Variable names should be meaningful. Here, age is the correct variable name.
3fill in blank
hardFix the error in the code to correctly declare a string variable with value "C#".
C Sharp (C#)
string language = [1]C#[1];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using single quotes which are for characters, not strings.
✗ Incorrect
Strings in C# must be enclosed in double quotes "".
4fill in blank
hardFill the blank to create a simple if statement that checks if number is greater than 10.
C Sharp (C#)
if (number [1] 10) { Console.WriteLine("Number is greater"); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using < or == which do not check for greater than.
✗ Incorrect
The operator > checks if the left value is greater than the right value.
5fill in blank
hardFill all three blanks to declare a list of integers and add the number 5 to it.
C Sharp (C#)
List<int> numbers = new [1]<int>(); numbers.[2](5); Console.WriteLine(numbers.[3]);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using Array instead of List.
Using wrong method names like Insert instead of Add.
Using Length instead of Count for List.
✗ Incorrect
Use List to create a list, Add to add an item, and Count to get the number of items.