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(); }
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(); }
Answer: Option B
Was this answer helpful ?
(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 ?
Submit Solution