ProgrammingHardWipro · Cognizant pattern
What is printed?
What is printed?
char *arr[] = {"one", "two", "three"};
char **p = arr;
printf("%s %c %s", *p, *(*(p + 1) + 1), p[2]);- A. one t three
- B. two w three
- C. one w two
- D. one w three
Correct answer: D. one w three
*p is arr[0] = "one". p+1 points to arr[1]="two"; *(p+1) is "two", and +1 into it gives 'w'. p[2] is arr[2] = "three".
More C Programming questions
- What is printed? Assume 32-bit int. c int flags = 0; flags |= (1 << 2); flags |= (1 << 4); flags &= ~(1 << 2); printf("%d", flags);
- What can be said about this program? c #include <stdlib.h> int main(void) { int p = malloc(sizeof(int)); free(p); free(p); }
- What is printed? c void modify(int arr[10]) { printf("%lu ", sizeof(arr)); } int main(void) { int a[10]; printf("%lu ", sizeof(a))…
- What is printed? const qualifies what p points to, not p itself. c int x = 5, y = 10; const int p = &x; p = &y; printf("%d", p);
- What is printed? c int a = 10; int p = &a; int q = p; p = NULL; printf("%d", q);
- What is printed? c int f(int n) { if (n == 0) return 0; return n + f(n - 1); } int main(void) { printf("%d", f(4)); }