Discussion :: C#.Net MCQs
-
What is the output for the following code ? static void Main(string[] args){int a = 5;if (Convert.ToBoolean((.002f) -(0.1f)))Console.WriteLine("Sachin Tendulkar");else if (a == 5)Console.WriteLine("Rahul Dravid");elseConsole.WriteLine("Ms Dhoni");Console.ReadLine();}
Answer : Option B
Explanation :
(0.002 “ 0.1f) not equivalent to zero hence it is true. So,only first if clause will execute and print:Sachin Tendulkar on console.As,first condition is always true so no else if statement will be executed. Output: Sachin Tendulkar
Be The First To Comment