0
What is the output of this code:
int a = 2; int b = 4; Console.Write(a); Console.Write(b);
2 Answers
+ 1
On the same line 24
+ 1
@Naomi The reason why it is 24, because Console.Write does not contain a new line at the end which would cause the next line of output to be on its own line.. If the exercise had been
int a = 2;
int b = 4;
Console.WriteLine(a);
Console.WriteLIne(b);
Then the output would be
2
4
alternatively, they could have written it like
Console.Write(quot;{a}{b}"); which yields the same output as the code in your question.
24