2,201 views
3 3 votes

What is the output of the following ?

int main()

{

int arr[2][3][2]={1,2,3,4,5,6,7,8,9,10,11,12};

printf("%d%d", a[1]-a[0], a[1][0]-a[0][0]);

return 0;

}

1 Answer

Best answer
9 9 votes

Ans will be 3, 6 (no matter what you take integer size - because that efferct will be normalized) I have taken 2 B.

Just refer following diagram, a[1]-a[0] = 106-100/size of int = 6/2 = 3

a[1][0]-a[0][0] = 212 - 200/size of int = 12/2 = 6

• selected by
Position:
Show:

Related questions

8 8 votes
1 1 answer
237
237 views
GO Classes asked Jun 20
237 views
What is the output of the following code?#include <stdio.h int main() { int a[] = {5, 10, 15}; int *p = a; printf("%d ", (*p)++); printf("%d ", *p++); printf("%d ", ++*p)...
5 5 votes
1 1 answer
206
206 views
GO Classes asked Jun 19
206 views
What is the output of the following code?#include <stdio.h int main() { int a[] = {2, 4, 6, 8}; int *p = a; p = p + 2; printf("%d %d", *p, p[-1]); return 0; }$\texttt{6 4...
7 7 votes
2 2 answers
339
339 views
GO Classes asked Jun 29
339 views
What is the output of the following code?#include <stdio.h struct Item { int code; int price; }; void update(struct Item *p) { p->price = p->price + 20; (*p).code = (*p)....
6 6 votes
2 2 answers
306
306 views
GO Classes asked Jun 29
306 views
What is the output of the following code?#include <stdio.h struct Box { int width; int height; }; int main() { struct Box b = {4, 6}; struct Box *p = &b; p->width = p->wi...