Professional Documents
Culture Documents
ID_________________
1. Which of the following correctly declares 8. What will be the output of the following code
an array? strip?
A. int anarray[10]; B. int anarray; for(i=0;i<5;i++)
for(j=0;j<1;j++)
C. anarray{10}; D. array anarray[10];
printf(a);
2. What is the index number of the last
A. aaaaa B. aaaa
element of an array with 29 elements? C. aaaa D. aaaaaaaaaa
A. 29 B. 28
C. 0 D. Programmer-defined 9. What will be the value of s?
3. Which of the following statement is int s=0;
correct? for(i=1;i<5;i++)
A. All array elements are of same type. s+=i;
B. An array will have default value zero.
C. An array can always be integer. A. 6 B. 15
D. None of the above. C. 10 D. None of the option
4. What will be the output of the following
code 10. What will be the output of the following code
main() #include<stdio.h>
{ int main()
int a[10] ={1,2,3}; {
printf(%d,a[5]); int a = 500, b = 100, c;
} if(!a >= 400)
A. 0 B. error b = 300;
C. garbage value D. 1 c = 200;
5. What will be the output of the following printf("b = %d c = %d\n", b, c);
code return 0;
main() }
{
int a[10] ={1,2,3}; A. b = 300 c = 200
printf(%d,a[0]); B. b = 100 c = garbage
} C. b = 300 c = garbage
A. 0 B. error D. b = 100 c = 200
C. garbage value D. 1
11. What will be the output of the following code
6. What is the size of an array int main()
main() {
{ int s=0,n=12;
int a[] ={1,2,3}; while(n!=0)
} {
A. 0 B. 3 s=s+n%10;
C. 2 D. error in code n/=10;
}
7. If an array is declared as, int a[7],what is printf(%d, s);
its size in the memory? }
A. 7 B. 6
C. 14 D. 12 A. 0 B. 3 C. 12 D. NONE