Question discussion

What is the output of the following C program?#include int main() { char c = 'A'; c += 3; printf("%c %d", c, c); return 0; }

1537Medium DSSSB TGT Computer Science 0 replies 1 views
0

What is the output of the following C program?

#include <stdio.h>
int main() {
    char c = 'A';
    c += 3;
    printf("%c %d", c, c);
    return 0;
}
  • AD 3
  • BC 67
  • CD 68
  • D68 D
Correct answer: C

Explanation

'A' has ASCII code 65, so c becomes 68, which prints as 'D' with %c and as 68 with %d.

Discussion 0

Nobody has replied yet. Start the discussion!