-
What will be the output of the following C code?
#include <stdio.h>
int main()
{
void *ptr1;
int num[5] = {10, 20, 30, 40, 80};
ptr1 = &num[4];
int *ptr2 = &num[3];
int R = ptr1 - ptr2;
printf("%d\n", R);
}
-
- 80
- 40
- 30
- 20
- Compilation Error
Correct Option: A
Compilation Error
main.c: In function ‘main’:
main.c:8:22: error: invalid operands to binary - (have ‘void *’ and ‘int *’)
int R = ptr1 - ptr2;