C Array Questions and Answers
Arrays in C language form the foundation of data storage and manipulation. They store multiple values of the same type under a single variable name, allowing efficient data handling. Programming questions and answers related to arrays frequently appear in campus placement exams and coding interviews by TCS, Wipro, and Capgemini. This topic includes C array questions with answers covering array declaration, initialization, multidimensional arrays, and pointer relations. Practicing these problems will enhance your understanding of indexing, memory usage, and algorithm design for real-world applications.
C Array
Showing 10 of
108 questions
41. In case of an upper triangular array whoch of the following is true.
- All the elements upper the diagonal element is zero.
- All the elements are zero.
- All the elements belowe the diagonal element are zero.
- All the diagonal elements are zero
42. Find the output void main ( ) { int x [ ] ={5, 6, 7, 8, 9}; printf("%d %d", (x+1) [0], (x-1)[2]); }
- 6 garbage
- 6 7
- 6 6
- None of these
43. Find the out the difference between the address of array and address of the first element of array
- They are the same thing.
- The address of the first element is a pointer to first element and the address of the array is a pointer to whole array
- The array name itself is a pointer and also the array is pointer.
- None of the above
44. Find the output void main ( ) { int a[] [3] = { 1, 3, 5, 4, 7, 9}; printf("%d %d", *(*(a+0) +0, *(*(a+1) +1)); }
- 1 3
- 1 7
- 1 5
- None of these
45. Find the output void main () { int x=5; char a[x]={'a','b','d'}; printf ("%c", ++1 [a]); }
- b
- c
- d
- Compilation error
46. Find the outpu void main () { int *p; int a [ ]={1, 2, 3, 4, 5, 6, 7, 8, 9}; p=(a+2) [2]; printf("%d", p); }
- 3
- 4
- 5
- Error
47. Find the output void main ( ) { int i,j, a[10]={1, 2, 3, 34, 5, 6, 7, 8, 9, }; int b[10]={11, 12, 13, 14, 15, 16, 17, 18, 19, 20}; ++b [j=i=++a[1]]; while (j==i) { if (b[i]==9) ++b[--i]; else b[(i<9)?++i:i]=b[j]+1; ++a[i]; } printf("a'%d]=%u",i, a[i]); }
- a[3] = 4
- a[4] = 6
- a[4] = 5
- Compilation error
48. Find the output void main ( ) { int a [3] [3], i, j, p, b=1; for (i=0; j<3;i++) for (j=0l j<3; j++) a [i][j]=++b; p=*(*(a+2)-3); p=*(*(a+2)-3); printf("%d",p); }
- 5
- 7
- 9
- 2
49. Find the output voia main ( ) { int a[ ] = {1, 2, 3, 4, 5}; int *p=(int *) (&a+1); printf("%d %d", *(a+1), *(p-1); }
- 2 0
- 1 0
- 2 5
- 1 garbage
50. Which of the following statements results an error of 1value required ? 1. void main (){ 2. int a[ ] ={1, 2, 3, 4, 5}; 3. int (*p) [5], *q[5]; 4. p=a; 5. q=a; 6. p=&a; 7. q=&a; 8. }
- line 4 & 6
- line 5 &7
- line 4 & 5
- line 6 & 7