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
11. The function strstr () returns
- Length of the initial substring
- Pointer to the first occurrence of the string
- Pointer to the next token in the string
- Pointer to the last occurrence of the string.
12. Which of the following is/are wrong ? int a,b[5], c[3] I. a=b[2]; II. b[3]=a; III. b[1]=c[2]; IV. C[0]=B[2];
- only II
- II & III
- III & IV
- None of the above
13. Find the output void main() { int a[ ] ={1, 2, 3, 4, 5}, k=1; while (k<=5) { printf("%d", k[a-1]); k++; } }
- 5 4 3 2 1
- 1 2 3 4 5
- Routime error
- Compilation error
14. How to measure total size of an integer array ?
- 2 * array size
- sezeof(int)*array size
- 4 * array size
- None of these
15. Which of the following is/are false regarding array ? I. Array index starts from -1. II. Array elements are stored in contiguous memory location. III. The size of the array should be mentioned while declaraing. IV. Array elements can be accessed using the inded of array
- only I
- Only III
- III & IV
- I &III
16. What heppens when subscript used for an array exceeds the array size ?
- Compiler gives an error message
- Simply placed excess data outside thearray
- Simply placed excess data on top of other data or on the program itself.
- Memory dump
17. Find the output. void main () { static int a[ ]={1 2, 3, 4, 5}; int i; for (i=0; i<5; i++) { *(a+i)=a[i] + i[a]; printf(%d", * (i+a)); }
- 2 4 6 8 10
- 1 3 5 7 9
- Expression syntax error
18. Find the output void main ( ) { int a[] ={1, 2, 3, 4, 5}, i; for (i=0; i<5; i++) { if (i<3); printf("%d",a[i]); else printf("hi"); } }
- 123hihi
- hahi
- 12345
- Compilation error
19. The array a[j][k] is equivalent to
- ((base type*)a+(j*row length)+k)
- *((base type*)a+(j*row length)+k)
- *(*((base type*)a+(j*row length)))+k)
- None of these
20. Find the output void main ( ) { int a [ ] = {4, 5, 6, 7, 8}, i, *p; for (p=a+4, i=2; i<=4; i++) printf ("%d",p[-i]); }
- Compilation error
- 6 5 4
- 8 7 6 5 4
- 6 7 8