Sail E0 Webinar
Question
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");      else      Console.WriteLine("Ms Dhoni");      Console.ReadLine();  }
Options:
A .  Rahul Dravid
B .  Sachin Tendulkar
C .  Ms Dhoni
D .  Warning : Unreachable Code
Answer: Option B


(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



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers