C Array Questions and Answers

Practice Mode
Showing 10 of 108 questions
Q81
In terms of code generation, how do the tweo definitions of buf, both presented below, differ? char buf [ ]="Hellow World"; char *buf="Hello world!";
  • A the first definition certainly allows the contents of but to be safely modified at runtime, the second definition does not.
  • B the first definition is not suitable for usage as an argument to a function call; the second definition is.
  • C the first definition is not legal because it does not indicate thesize of the array to be allocated. the second definition is legal.
  • D The first definition does not allocate enoughl space for a terminating Null character, not does it append one; the seond definition does.
Answer: Option A
Q82
Whch of the following is equivalent to *(a[3]+2).
  • A a [3] [2]
  • B ((*a+3)+2)
  • C (*(a+3)+2)
  • D None of the above
Answer: Option A
Q83
Which of the following creates a single dimensional array equivalent to the dynamic array ? char x[30];
  • A char *const x=(char *const) malloc (30);
  • B char *x=(char *) malloc (30);
  • C char *x=(const char*) malloc (30);
  • D None of the above
Answer: Option A
Q84
What is the length of the following string ? char x[ ] ="8, 9, 10, 11, 12, ";
  • A 5
  • B 6
  • C 8
  • D 12
Answer: Option D
Q85
Find the output void main () { int x[ ]={1, 2, 3, 4, 5, 6}; int *p,q,r; p=x+3; q=5, r=4; printf("%d", p[(q>r)-2]); }
  • A 4
  • B 3
  • C 5
  • D Compilation error
Answer: Option B
Q86
Find the output. void main () { int p[4]={15, 25, 35, 45}, *a; p[-1]=5; a=p; printf("%d", -1[++a]); }
  • A -35
  • B 25
  • C -5
  • D Compilation error
Answer: Option A
Q87
Find out the output void main ( ) { int a[ ]={1, 2, 3, 4, 5, 6}; int *ptr=a+2; printf("%d %d', --*ptr+1, 1+*--ptr); }
  • A 13
  • B 12
  • C 23
  • D Compilation error
Answer: Option C
Q88
Find the output void main () { char a[ ] = {'1', '2', '3', 0, '1', '2', '3' }; printf(a); }
  • A 123
  • B 123123
  • C 1230123
  • D Compilation error
Answer: Option A
Q89
Find the output int one_d[ ]={1, 2, 3}; void main ( ) { int *ptr; ptr=one_d; ptr+=-3&2&&-5; ptintf ("%d", *ptr); }
  • A 1
  • B 2
  • C 3
  • D Compilation error
Answer: Option A
Q90
Find the output { void main ( ) { char a[5]="abcd"; int b = 3; printf("%c\n", a[b]); printf("%c", ((char*)b) [(int)a]); }
  • A Compilation Error
  • B d d
  • C d Garbage value
  • D None of these
Answer: Option B
Questions and Answers for Competitive Exams Various Entrance Test