Can you Explain this code's output? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can you Explain this code's output?

#include <stdio.h> #include <stdlib.h> int main(void) { int i,j; int **p = (int **)malloc(2 * sizeof(int *)); p[0] = (int *)malloc(2 * sizeof(int)); p[1] = p[0]; for(i = 0; i < 2; i++) { for(j = 0; j < 2; j++) { p[i][j] = i + j; printf("%d\n",p[0][0]); }} printf("\n%d",p[0][0]); return 0; }

22nd Oct 2017, 8:25 AM
Gaurav Sukhatme
Gaurav Sukhatme - avatar
0 Answers