ProgrammingModerateTCS NQT · Wipro
What is printed?
What is printed?
#include <stdio.h>
struct item { int w, v; };
int main(void) {
struct item items[] = {{1, 10}, {2, 20}, {3, 30}};
struct item *p = items + 1;
printf("%d", p->v + (p + 1)->w);
}- A. 21
- B. 23
- C. 30
- D. 22
Correct answer: B. 23
p->v is items[1].v = 20, and (p + 1)->w is items[2].w = 3, so the sum is 23.
More C Programming questions
- What is printed? c #include <stdio.h> int main(void) { const char s = "hello"; printf("%c%c", s[1], (s + 4)); }
- What is printed? c #include <stdio.h> int main(void) { int x = 1, y = 2; const int cp = &x; int const pc = &y; pc = 5; printf("%d %d", cp…
- What is printed? Assume double is 8 bytes. c #include <stdio.h> int main(void) { printf("%zu", sizeof(1 ? 'a' : 1.0)); }
- What is printed? c #include <stdio.h> #include <stdlib.h> #include <string.h> int cmp(const void a, const void b) { return strcmp((const…
- What index is printed when bsearch looks up "cat" in the sorted array {"ant", "bee", "cat", "dog"}? c #include <stdio.h> #include…
- How many ordered ways are there to write 10 as a sum of 1s, 2s and 3s? Compute with this program. c #include <stdio.h> int f(int n) { if…