Control Instructions - Programming

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.