GATE Assistant

Past questions › Computer Science and Information Technology › GATE 2022

GATE 2022 · CS · MCQ · 2 marks · Programming and Data Structures › C Programming Fundamentals

GATE 2022 Computer Science and Information Technology question: What is printed by the following ANSI C program? code ASCII encoding for relevant…

What is printed by the following 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 encoding for relevant characters is given below

A B C ... Z
65 66 67 ... 90
a b c ... z
97 98 99 ... 122
* + -
42 43 45
  1. (A)

    z K S

  2. (B)

    122 75 83

  3. (C)
  4. (D)

    P x +

Show answer

Official answer: A

Practise this question with exam-style marking

Discussion

No discussion yet.

Join the discussion