Question
The program below was written using if statements, but then the author decided to implement the code more efficiently. Take the area that has been block-commented and execute the same functionality as above, in a single line of code, using the conditional operator - https: //msd.microsoft.com/en-us/library/ty67wk28.aspx: class Program { static void Main (string[] args) [/* if (input A > 3) indicator = "small": else indicator = "tiny": if (input B > 3) indicator = "big": *///Execute same functionally as above in a single line, using conditional operator = ? : ...//Executes same functionally as above } }
Explanation / Answer
The following highlighted code is the equivalent code fo if conditions.
public class Program
{
public static void main(String args[])
{
indicator = (inputB > 3)?"big":(inputA > 3)?"small":"tiny";
}
}