Question 1: What will be the output of the following C code? void main(void) { int *a, S = 0, n = 3, i; a = (int*)malloc
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Question 1: What will be the output of the following C code? void main(void) { int *a, S = 0, n = 3, i; a = (int*)malloc
Question 1: What will be the output of the following C code? void main(void) { int *a, S = 0, n = 3, i; a = (int*)malloc(n*sizeof(int)); for(i=0; i<n; i++) *(a + i) = S + i; S = *(a + 2); printf("%d ", S); } ANSWER:............ Question 3: What will be the output of the following C code? void main(void) { int *a, i, S = 0, n = 4; a = (int*) malloc(n*sizeof(int)); for(i=0; i<n; i++) *(a+i) = 1; S = *a + 1 + *(a + 1); printf("%d", S); Question 2: What will be the output of the following C code? void main(void) { int a[4] =(4,3,2,1); int b[4] = {0}; int S, i; for (i = 0; i < 4; i++) if (a%2 == 0) b = a; S = b[1]; printf("%d ", S); } ANSWER:.. Question 4: What will be the output of the following C code? void main(void) { int *a,b[3] = {3}; int S = 1; a = b; S = *(a + 2) + *a; printf("%d", S); ANSWER:..