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

Console.WriteLine and Write methods in C Sharp (C#) - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Console Output Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of mixed Write and WriteLine calls
What is the output of the following C# code?
C Sharp (C#)
Console.Write("Hello");
Console.WriteLine(" World");
Console.WriteLine("!");
A
!
dlroW olleH
B
Hello World!
C
Hello
 World
!
D
Hello World
!
Attempts:
2 left
💡 Hint
Remember that Write does not add a new line, but WriteLine does.
Predict Output
intermediate
2:00remaining
Output with multiple Write calls
What will be printed by this code snippet?
C Sharp (C#)
Console.Write("A");
Console.Write("B");
Console.WriteLine("C");
Console.WriteLine("D");
A
ABCD
B
ABC
D
C
A
B
C
D
D
AB
CD
Attempts:
2 left
💡 Hint
Write does not add a new line, WriteLine does.
Predict Output
advanced
2:00remaining
Output of WriteLine with format string
What is the output of this code?
C Sharp (C#)
int x = 5;
int y = 10;
Console.WriteLine("Sum of {0} and {1} is {2}", x, y, x + y);
A
Sum of 5 and 10 is 15
B
Sum of {0} and {1} is {2}
C
Sum of 5 and 10 is {2}
D
Sum of x and y is 15
Attempts:
2 left
💡 Hint
Check how placeholders {0}, {1}, {2} are replaced by arguments.
Predict Output
advanced
2:00remaining
Effect of WriteLine with no arguments
What does this code print?
C Sharp (C#)
Console.Write("Line1");
Console.WriteLine();
Console.WriteLine("Line3");
A
Line1

Line3
B
Line1Line3
C
Line1
Line3
D
Line1
 Line3
Attempts:
2 left
💡 Hint
WriteLine with no arguments just moves to the next line.
Predict Output
expert
2:00remaining
Output of nested Write and WriteLine with escape sequences
What is the output of this code?
C Sharp (C#)
Console.Write("Start\n");
Console.WriteLine("Middle\tEnd");
Console.Write("Finish");
A
hsiniF
dnE	elddiM
tratS
B
Start

Middle	End
Finish
C
Start
Middle	End
Finish
D
hsiniF
dnE	elddiM

tratS
Attempts:
2 left
💡 Hint
Remember \n is newline and \t is tab. WriteLine adds a newline after printing.