Control Instructions

Q1:
Which of the following code snippets are the correct way to determine whether a is Odd or Even?
  1. int a;
    String res; 
    if (a % 2 == 0)
        res = 'Even'; 
    else 
        res = 'Odd';
  2. int a; 
    String res; 
    if (a Mod 2 == 0) 
        res = 'Even'; 
    else
        res = 'Odd';
  3. int a;
    Console.WriteLine(a Mod 2 == 0 ? 'Even': 'Odd');
  4. int a; 
    String res;
    a % 2 == 0 ? res = 'Even' : res = 'Odd';
    Console.WriteLine(res);

A 1, 3

B 1 Only

C 2, 3

D 4 Only

E None of these

ANS:B - 1 Only

No answer description is available. Let's discuss.



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.