Question
Official answer and solution
- Official answer
- A
- From
- Official GATE 2022 answer key
Solution
Compute bitwise AND, OR, and XOR operations on ASCII values and add/subtract character offsets.
Given ASCII values from the table:
'P'= 80 ='x'= 120 ='*'= 42'-'= 45'+'= 43
Evaluating each variable:
-
ASCII 122 is
'z'. -
ASCII 75 is
'K'. -
ASCII 83 is
'S'.
printf("%c %c %c\n", c, d, e) prints z K S.
Final answer
Option (A)
Common trap
Printing the integer ASCII numbers instead of formatting them as characters using %c.
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2022 Computer Science and Information Technology (CS)
- Question
- 44 of 65
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.