Home »
MCQs »
C# MCQs
What will be the output of the following C# code, if the input is 123? | Question 4
33. What will be the output of the following C# code, if the input is 123?
using System;
namespace MyApplication {
class Program {
static void Main(string[] args) {
Console.WriteLine("Enter a number:");
int num = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Given number is: " + num);
}
}
}
- Given number is:123
- Given number is: 123
- Given number is: "123"
- Error
Answer: B) Given number is: 123
Explanation:
In C#, Console.ReadLine() is used to read the string and here the input is 123 and converting it into an integer. This, there will not be an error.
Output will be: Given number is: 123