×

Multiple-Choice Questions

Web Technologies MCQs

Computer Science Subjects MCQs

Databases MCQs

Programming MCQs

Testing Software MCQs

Digital Marketing Subjects MCQs

Cloud Computing Softwares MCQs

AI/ML Subjects MCQs

Engineering Subjects MCQs

Office Related Programs MCQs

Management MCQs

More

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);
    }
  }
}
  1. Given number is:123
  2. Given number is: 123
  3. Given number is: "123"
  4. 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

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.