ProgrammingVery hardProduct company OA
What is printed? Assume sizeof(int) == 4.
What is printed? Assume `sizeof(int) == 4`.
int a[4] = {1, 2, 3, 4};
int *p = a;
printf("%d ", *(p++));
printf("%d ", *(++p));
printf("%d", *p++ + *p);- A. 1 3 6
- B. 2 3 7
- C. 1 3 7
- D. 1 4 7
Correct answer: C. 1 3 7
*(p++): prints a[0]=1, p now a+1. *(++p): p advances to a+2 first, prints a[2]=3. *p++ + *p: reads a[2]=3, p advances to a+3, then *p reads a[3]=4: 3+4=7.
More C Programming questions
- What is printed? c int a, b, c; a = b = c = 5; printf("%d %d %d", a, b, c);
- file1.c: c static int secret = 7; int getSecret(void) { return secret; } file2.c: c int getSecret(void); int main(void) { printf("%d"…
- What is printed? c int a[3][4] = {{1,2,3,4},{5,6,7,8},{9,10,11,12}}; int p = (int )a; printf("%d %d %d", (p + 5), ((a + 1) + 2), (a[2] +…
- Which identifier, even though declared at file scope, never has linkage at all in C?
- What can printf legally print here? c int i = 0; printf("%d %d %d", i++, i++, i++);
- What happens when this is compiled? c int compute(int x); static int compute(int x) { return x 2; } int main(void) { printf("%d"…