In this program the two printed memory locations has the difference of . . . . . . . . bytes.
#include<stdio.h>
#include<stdlib.h>
int main()
{
int *ptr;
ptr = (int*)malloc(sizeof(int)*2);
printf("%p\n",ptr);
printf("%p\n",ptr+1);
return 0;
}
#include<stdio.h>
#include<stdlib.h>
int main()
{
int *ptr;
ptr = (int*)malloc(sizeof(int)*2);
printf("%p\n",ptr);
printf("%p\n",ptr+1);
return 0;
}A. 1
B. 4
C. can not be determined
D. none of the mentioned
Answer: Option B

Join The Discussion