ProgrammingModerateTCS NQT · Wipro
Assume ASCII. What is printed?
Assume ASCII. What is printed?
int x = 'A' + 1.5;
printf("%c %d", x, x);- A. B 66
- B. B 66.5
- C. C 67
- D. A 65
Correct answer: A. B 66
'A' + 1.5 is computed in double as 66.5; storing it in an int truncates it to 66, which is the code of 'B'. 'C 67' rounds instead of truncating.
More C Programming questions
- Given int m[3][4];, why can m not be passed to a function declared void f(int p);?
- Assume C99 or later. What is printed? c void f(int n, int a[][n]) { printf("%zu", sizeof a[0] / sizeof a[0][0]); } int main(void) { int…
- What is printed? c int c = 0; for (int i = 1; i <= 10; i++) for (int j = i; i j <= 10; j++) c++; printf("%d", c);
- What does z("abcdef") print? c void z(const char s) { if (!s) return; putchar(s); z(s + 2); if (s[1]) putchar(s[1]); }
- Does this function compile, and what does it do? c struct S { int p; }; void f(const struct S s) { s->p = 5; }
- On a two's-complement machine, what is printed? c int x = 5; printf("%d %d", -~x, ~-x);