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
101. Find the output void main ( ) { char s[10]; char *p,c='1'; strcpy (s, "hello sir"); p=strchr (s, c); if (p) prntf("%d", p-s); else printf("Not found"); }
- 2
- 3
- Compilation error
- Not found
102. Find the output void main ( ) { int a[4]={1, 3, 5, 7}; int (*p) [4]; p=&a; printf("%d %d,**p++,*(*p+1)); }
- 1 3
- 1 5
- 3 5
- 3 7
103. Find the output. void main () { int a[2] [3] [1]={1, 2, 3, 4, 5, 6}; int i=1; printf(%d %d", *(*(*(a+i++))), ***a+i); }
- 4 2
- 2 3
- 4 3
- 2 2
104. Find the output. void main () { char sting [4] [1] [3]= {"hi", "1a", "ks", "ya'}; printf("%c %c %c", *(sting [2][0]+1), *(*sting [1]+1), ***(sting +2)); }
- s 1 k
- s a k
- k a k
- Garbage value
105. Find the output. void main () { int x[ ] [3]={2, 4, 6, 8, 10, 12}; int (*y) [3]; y=x; printf("%d %d", *(y+1) [0], *(y+0)[1]); }
- 2 8
- 8 8
- 8 10
- 2 2
106. Find the output void main ( ) { float x [3] [2]={1, 2, 3, 4, 5, 6}; float (*y) [3]; y=x; prrintf("%f %f", *(y+0) [1],* (y+1) [0]); }
- 4.000000 4.000000
- 4.000000 1.000000
- 4.000000 5.000000
- None of these
107. Find the output void main () { int a[ ] [3]={1, 2, 3, 4,5,6,7, 8, 9}; int i; for (i=0; i<3; i++) printf("%d", *(*(a+1))+i); }
- 1 2 3
- 1 5 9
- 1 4 7
- None of these
108. Find the output void main () { char s [ ]={78, 111, 32, 111, 117, 116, 112, 117, 116, 0}; printf("%s", s); }
- Compilation error
- Garbage value
- No ouput
- New year