935 views
0 0 votes
What will be the output of the program assuming that the array begins at the location 1002 and size of an integer is 4 bytes?
#include<stdio.h>

int main()
{
    int a[3][4] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
    printf("%u, %u, %u\n", a[0]+1, *(a[0]+1), *(*(a+0)+1));
    return 0;
}
    A.    448, 4, 4
    B.    520, 2, 2
    C.    1006, 2, 2
    D.    Error

1 Answer

0 0 votes
C should be the answer as the a[0] + 1 is the base address + 1 ie 1002 + 4 = 1006.
other two are the same is writting the a[0][1].
a[0] can be written as *a.
a[5] can be written as *(a + 5 ).
Position:
Show:

Related questions

5 5 votes
2 2 answers
738
738 views
amar100 asked Nov 3, 2024
738 views
#include <stdio.h int main() {short a[3] = {3, 6, 9, 12, 15, 18};printf("%d\n", *(a + 1) );return 0; }The output is 15. How is the output is 15? , In my thinking it must...
1 1 vote
2 2 answers
2.4k
2.4k views
bharti asked Aug 23, 2017
2,386 views
#include "stdio.h" int * gPtr;int main(){int * lPtr = NULL;if(gPtr == lPtr){printf("Equal!");}else{printf("Not Equal");}return 0;}what will be the outpout :A. it will alw...
2 2 votes
4 4 answers
1.8k
1.8k views
Anil Khatri asked Sep 9, 2016
1,769 views
What will be the output of the program?#include<stdio.h int main() { const c = -11; const int d = 34; printf("%d, %d\n", c, d); return 0; } A. Error B. -1...
0 0 votes
2 answers 2 answers
2.4k
2.4k views
Anil Khatri asked Sep 8, 2016
2,375 views
What will be the output of the program?#include<stdio.h>int main(){ char c=48; int i, mask=01; for(i=1; i<=5; i++) { printf("%c", c|mask); mask ...