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

Why console IO is important 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 print a message to the console.

C Sharp (C#)
Console.[1]("Hello, world!");
Drag options to blanks, or click blank then click option'
AWrite
BReadLine
CWriteLine
DRead
Attempts:
3 left
💡 Hint
Common Mistakes
Using ReadLine instead of WriteLine causes the program to wait for input.
Using Write prints without moving to a new line.
2fill in blank
medium

Complete the code to read a line of input from the user.

C Sharp (C#)
string input = Console.[1]();
Drag options to blanks, or click blank then click option'
AReadLine
BWriteLine
CWrite
DRead
Attempts:
3 left
💡 Hint
Common Mistakes
Using WriteLine instead of ReadLine causes no input to be read.
Using Read reads a single character, not a full line.
3fill in blank
hard

Fix the error in the code to correctly print the user's name.

C Sharp (C#)
Console.WriteLine("Hello, " + [1]);
Drag options to blanks, or click blank then click option'
Ainput
BConsole.ReadLine()
CConsole.WriteLine()
DConsole.Read()
Attempts:
3 left
💡 Hint
Common Mistakes
Using Console.ReadLine() inside WriteLine causes the program to wait for input again.
Using Console.WriteLine() inside WriteLine is incorrect syntax.
4fill in blank
hard

Fill both blanks to read an integer from the user and print it.

C Sharp (C#)
int number = int.Parse(Console.[1]());
Console.[2]($"You entered: {number}");
Drag options to blanks, or click blank then click option'
AReadLine
BWriteLine
CWrite
DRead
Attempts:
3 left
💡 Hint
Common Mistakes
Using Read instead of ReadLine reads only one character.
Using Write instead of WriteLine does not move to a new line.
5fill in blank
hard

Fill all three blanks to read two numbers, add them, and print the result.

C Sharp (C#)
int num1 = int.Parse(Console.[1]());
int num2 = int.Parse(Console.[2]());
int sum = num1 [3] num2;
Console.WriteLine($"Sum: {sum}");
Drag options to blanks, or click blank then click option'
AReadLine
B+
CRead
DWriteLine
Attempts:
3 left
💡 Hint
Common Mistakes
Using Read reads only one character, not the full number.
Using other operators like - or * will change the result.