|
INTERVIEW QUESTIONS
MAINFRAME
JCL
DETAILS
Question: 47) main( ) { int a[2][3][2] = {{{2,4},{7,8},{3,4}},{{2,2},{2,3},{3,4}}}; printf(“%u %u %u %d
”,a,*a,**a,***a); printf(“%u %u %u %d
”,a+1,*a+1,**a+1,***a+1); }
Answer: Answer: 100, 100, 100, 2 114, 104, 102, 3 Explanation: The given array is a 3-D one. It can also be viewed as a 1-D array. 2 4 7 8 3 4 2 2 2 3 3 4 100 102 104 106 108 110 112 114 116 118 120 122
thus, for the first printf statement a, *a, **a give address of first element . since the indirection ***a gives the value. Hence, the first line of the output. for the second printf a+1 increases in the third dimension thus points to value at 114, *a+1 increments in second dimension thus points to 104, **a +1 increments the first dimension thus points to 102 and ***a+1 first gets the value at first location and then increments it by 1. Hence, the output.
|
|
|
Category |
JCL Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.3) By 7369 users |
Added on |
9/2/2014 |
Views |
71696 |
Rate it! |
|
|
Question:
47) main( ) { int a[2][3][2] = {{{2,4},{7,8},{3,4}},{{2,2},{2,3},{3,4}}}; printf(“%u %u %u %d
”,a,*a,**a,***a); printf(“%u %u %u %d
”,a+1,*a+1,**a+1,***a+1); }
Answer:
Answer: 100, 100, 100, 2 114, 104, 102, 3 Explanation: The given array is a 3-D one. It can also be viewed as a 1-D array. 2 4 7 8 3 4 2 2 2 3 3 4 100 102 104 106 108 110 112 114 116 118 120 122
thus, for the first printf statement a, *a, **a give address of first element . since the indirection ***a gives the value. Hence, the first line of the output. for the second printf a+1 increases in the third dimension thus points to value at 114, *a+1 increments in second dimension thus points to 104, **a +1 increments the first dimension thus points to 102 and ***a+1 first gets the value at first location and then increments it by 1. Hence, the output.
Source: CoolInterview.com
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
|
46) main() { show(); } void show() { printf("I'm the greatest"); }
|
} - JCL Interview Questions & Answers">
View Answer
|
|
45) main() { extern out; printf("%d", out); } int out=100;
|
} int out=100; - JCL Interview Questions & Answers">
View Answer
|
|
44) main() { printf("%d", out); } int out=100;
|
} int out=100; - JCL Interview Questions & Answers">
View Answer
|
|
43) main() { extern int i; i=20; printf("%d",sizeof(i)); }
|
} - JCL Interview Questions & Answers">
View Answer
|
|
42) #include<stdio.h> main() { struct xx { int x; struct yy { char s; struct xx *p; }; struct yy *q; }; }
|
View Answer
|
|
41) #include<stdio.h> main() { struct xx { int x=3; char name[]="hello"; }; struct xx *s=malloc(sizeof(struct xx)); printf("%d",s->x); printf("%s",s->name); }
|
View Answer
|
|
40) #include<stdio.h> main() { char s[]={'a','b','c','
','c','
|
View Answer
|
|
39) main() { int i=0; for(;i++;printf("%d",i)) ; printf("%d",i); }
|
printf("%d",i); } - JCL Interview Questions & Answers">
View Answer
|
|
38) #define f(g,g2) g##g2 main() { int var12=100; printf("%d",f(var,12)); }
|
} - JCL Interview Questions & Answers">
View Answer
|
|
37) main() { int i; printf("%d",scanf("%d",&i)); // value 10 is given as input here }
|
}
View Answer
|
|
36) #include<stdio.h> main() { int i=1,j=2; switch(i) { case 1: printf("GOOD"); break; case j: printf("BAD"); break; } }
|
View Answer
|
|
35) void main() { int i=5; printf("%d",i+++++i); }
|
} - JCL Interview Questions & Answers">
View Answer
|
|
34) void main() { int i=5; printf("%d",i++ + ++i); }
|
} - JCL Interview Questions & Answers">
View Answer
|
|
33) main() { static char names[5][20]={"pascal","ada","cobol","fortran","perl"}; int i; char *t; t=names[3]; names[3]=names[4]; names[4]=t; for (i=0;i<=4;i++) printf("%s",names[i]); }
|
- JCL Interview Questions & Answers">
View Answer
|
|
32) main() { int i=1; while (i<=5) { printf("%d",i); if (i>2) goto here; i++; } } fun() { here: printf("PP"); }
|
- JCL Interview Questions & Answers">
View Answer
|
|
31) main() { char *p; p="Hello"; printf("%c
",*&*p); }
|
printf("%c
",*&*p); } - JCL Interview Questions & Answers">
View Answer
|
|
30) main() { int i=400,j=300; printf("%d..%d"); }
|
} - JCL Interview Questions & Answers">
View Answer
|
|
29) void main() { char far *farther,*farthest; printf("%d..%d",sizeof(farther),sizeof(farthest)); }
|
View Answer
|
|
28) enum colors {BLACK,BLUE,GREEN} main() { printf("%d..%d..%d",BLACK,BLUE,GREEN); return(1); }
|
View Answer
|
|
main() { clrscr(); } clrscr();
|
View Answer
|
Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.
View All JCL Interview Questions & Answers - Exam Mode /
Learning Mode
|