Home »
MCQs »
C# MCQs
What will be the output of the following C# code? | Question 5
36. What will be the output of the following C# code?
using System;
namespace MyApplication {
class Program {
static void Main(string[] args) {
int a = 10, b = 20;
Console.WriteLine("{0},{0}", a, b);
}
}
}
- 10,10
- 10,20
- 20,20
- Error
Answer: A) 10,10
Explanation:
In the above code, there are two variables a and b, but while printing the values of a and b, we are using the same placeholder {0}, that will print the value of the first variable. Thus, the output is 10,10.