C Array Questions and Answers

Practice Mode
Showing 10 of 108 questions
Q31
Which of the following operation is legal with array a[5]?
  • A a++
  • B a+1
  • C ++a
  • D a*2
Answer: Option B
Q32
Find the output void main  () { int array [ ] ={1, 3, 5, 7, 9}, *p, i; p=array [0]; for (i=0; i<5; i++) printf("%2d", ++*p); }
  • A 2 3 4 5 6
  • B 1 3 5 7 9
  • C 1 2 3 4 5
  • D 1 2 3 4 5 Null pointer assignment
Answer: Option D
Q33
This is a small program to find the maximum element in an array. How many comparisons in the below function to find the maximum element. int findmax (int A[ ], int n) { int max, i; max=A[0]; for (i=1; i<n; i++) if (A[i] >max) max =A[i]; return max ; }
  • A n-1
  • B n+1
  • C n/2
  • D n
Answer: Option A
Q34
Find the output void main ( ) int a[5]; a[-2]=5; a[2]=1; printf("%d", -2[a]); }
  • A 5
  • B -1
  • C Memory dump
  • D None of these
Answer: Option B
Q35
Find the output void main () [ int a[ ] ={1, 2, 3, 4, 5}, *p,*q; p=a; q=a; if (*p++==++*q) printf("Equal"); else printf("Not equal"); }
  • A Equal
  • B Not equal
  • C Compilation error
  • D None of these
Answer: Option A
Q36
Find the output void main () { int *p, a[5]={1, 2, 3, 4, 5} p=a; printf("%d %d %d", ++*p, ++*p); }
  • A 1 2 3
  • B 3 2 1
  • C 3 3 2
  • D None of these
Answer: Option C
Q37
Find the output void main( ) { int a[]={{1+2}, {3+4}, {5+6}}, i; for (i=0; i<3; i++) printf("%2d",a[1]); }
  • A 3 7 11
  • B 2 4 6
  • C 1 3 5
  • D Compilation error
Answer: Option A
Q38
Find the output int arr [ ]={1, 2, 3}; void main ( ) { int a, *p, b, c; a=51 %26; p=&a; a+=2; b=arrr[1]+a; c=*p+b; printf("%d %d %d", a, b, c); }
  • A 25 27 52
  • B 27 29 54
  • C 27 28 53
  • D 27 29 56
Answer: Option D
Q39
Find the output void main ( ) { int a[ ]={0, 0, 0, 0, 0, }, *p, i; p=a; for (i=0; i<5; i++) printf("%2d", ++*p+a [i]); }
  • A 1 2 3 4 5
  • B 2 2 3 4 5
  • C 1 1 1 1 1
  • D None of these
Answer: Option B
Q40
Find the output void main ( ) { int a [ ] [4]= {1, 2, 3, 4, 5, 6, 7, 8}; int (*p) [4]=a; printf("%d %d", (*p+1)[1], (*p) [2]); p++; printf("%d %d", (*%d %d", (*p+2) [0], (*p)[2]); }
  • A 2356
  • B 2256
  • C 3366
  • D 3377
Answer: Option D
Questions and Answers for Competitive Exams Various Entrance Test