What Will Be The Output Of The Following C Codep Pre Langcsharp #547
What will be the output of the following C# code?</p> <pre><code class="language-csharp" line="1"> static void Main(string[] args) { Console.WriteLine("This is a Console Application:"); Console.Write("Please enter your lucky number:"); string val1 = Console.ReadLine(); int val2 = System.Convert.ToInt32(val1, 10); val2 = val2 * val2; Console.WriteLine("square of number is:" +val2); Console.Read(); } </code></pre>
This multiple choice question (MCQ) is related to the book/course
gs gs108 CSharp.
It can also be found in
gs gs108 Console I/O Operations and Stream Classes - Introduction of Console I/O Operations - Quiz No.2.
What will be the output of the following C# code?
static void Main(string[] args) { Console.WriteLine("This is a Console Application:"); Console.Write("Please enter your lucky number:"); string val1 = Console.ReadLine(); int val2 = System.Convert.ToInt32(val1, 10); val2 = val2 * val2; Console.WriteLine("square of number is:" +val2); Console.Read(); }
Compile time error
Runs successfully does not print anything
Runs successfully, ask for input and hence displays the result
Syntax Error