OA. free
Free
Qualcomm Embedded Systems & Hardware Embedded Systems & Hardware Medium

Output: The best place is Ooty

Qualcomm technical mcq question, verified with a worked answer. Free to practise - no sign-up.

char *p = "Kerala", *q = "Ooty", *r = "Mysore", *s = "Shimoga";
enum loc{Kerala = 1, Ooty = 2, Mysore = 3, Shimoga = 4};
enum loc dir;

dir = Shimoga;
if (dir == Shimoga)
    printf("The best place is %s\n", s);
return 0;

Output: The best place is Ooty

Choose one option.
Show answer & explanation
Answer: C. C) The best place is Shimoga

The variable s points to string 'Shimoga'. When dir equals Shimoga, printf formats s, producing 'The best place is Shimoga'.

Step-by-step Derivation:
Step 1: dir is assigned Shimoga.
Step 2: The if-condition (dir == Shimoga) evaluates to true.
Step 3: printf prints string s which is "Shimoga".