Skip to content
Official PYQ · 2022

GATE CS 2022 Q34 — Programming in C

Explain with AI

What is printed by the following ANSI C\text{ANSI C} program?

#include<stdio.h>

int main(int argc, char *argv[]) {

    char a = ‘P’;

    char b = ‘x’;

    char c = (a&b) + ‘*’;

    char d = (a|b) – ‘-’;

    char e = (a^b) + ‘+’;

    printf(“%c %c %c\n”, c, d, e);

    return 0;

}

ASCII\text{ASCII} encoding for relevant characters is given below

ABC…Z656667…90abc…z979899…122∗+–424345\begin {array}{|c|c|c|c|c|} \hline \text{A} & \text{B} & \text{C} & \dots & \text{Z} \\ \hline 65 & 66 & 67 & \dots & 90 \\ \hline \end{array} \qquad \begin {array}{|c|c|c|c|c|} \hline \text{a} & \text{b} & \text{c} & \dots & \text{z} \\ \hline 97 & 98 & 99 & \dots & 122 \\ \hline \end{array} \\ \qquad \qquad \qquad \quad \begin {array}{|c|c|c|} \hline * & + & – \\ \hline 42 & 43 & 45 \\ \hline \end{array}

Choose one option
View answer

Answer: A

Worked explanation not available yet.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Programming in C questions