C Programming · Question 6 · Medium
What will be the output of the following C program?
#include <stdio.h>
int main(void) {
int a[] = {10, 20, 30, 40};
int *p = a;
p += 2;
printf("%d %d", *p, *(p - 1) + 1);
return 0;
}
- 30 20
- 20 11
- 30 21
- 12 21
Answer and explanation
Answer: C. 30 21
Explanation: p starts at a[0]; after p += 2 it points to a[2] = 30. *(p - 1) is a[1] = 20, and adding 1 gives 21.
Previous: What will be the output of the following C program? · Next: What will be the output of the following C program?
Practise c programming
Try a fresh set of c programming questions with an explanation after every answer, free and without signing up: C Programming practice. Or sit a full placement mock test.
More c programming questions
- What will be the output of the following C program?
- What will be the output of the following C program?
- What will be the output of the following C program?
- What will be the output of the following C program?
- What will be the output of the following C program?
- What will be the output of the following C program?
- What will be the output of the following C program?
- What will be the output of the following C program?
- What will be the output of the following C program?
- What will be the output of the following C program?
More technical & programming practice
Java · Python · Data Structures · Algorithms · Object-Oriented Programming · DBMS · SQL · Operating Systems
LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge