C Language - Arrays

You Are Here :: Home > C Language > Arrays - General Questions

 
19.

if an array is declared as a[10], then its elements will be stored as

A. a[1] to a[10]. B. a[1] to a[9].
C. a[0] to a[9]. D. a[0] to a[10].




20.

Consider the following program fragment:

int table[2][4], i, j;
Which one of the following sentences is true?

A. The code will cause compile-time errors. B. The code will compile but cause run-time errors.
C. The value of table[1][3] will be set to 4. D. The value of table[3][1] will be set to 4.




21.

main(){
int a[]={1,2};
printf("%d %d\n",a[0],a[1]);
a[1,0]=22;
printf("%d %d",a[0],a[1]);
}

A. 1 2
2 2
B. 1 2
1 2
C. 1 2
2 1
D. 1 2
22 2




22.

What will be the output of the program ?

#include
int main()
{
int a[5] = {5, 1, 15, 20, 25};
int i, j, m;
i = ++a[1];
j = a[1]++;
m = a[i++];
printf("%d, %d, %d", i, j, m);
return 0;
}

A. 2, 1, 15 B. 1, 2, 5
C. 3, 2, 15 D. 2, 3, 20




23.

What will be the output of the program ?

#include
int main()
{
static int a[2][2] = {1, 2, 3, 4};
int i, j;
static int *p[] = {(int*)a, (int*)a+1, (int*)a+2};
for(i=0; i<2; i++)
{
for(j=0; j<2; j++)
{
printf("%d, %d, %d, %d\n", *(*(p+i)+j), *(*(j+p)+i), *(*(i+p)+j), *(*(p+j)+i));
}
}
return 0;
}

A. 1, 1, 1, 1
2, 3, 2, 3
3, 2, 3, 2
4, 4, 4, 4
B. 1, 2, 1, 2
2, 3, 2, 3
3, 4, 3, 4
4, 2, 4, 2
C. 1, 1, 1, 1
2, 2, 2, 2
2, 2, 2, 2
3, 3, 3, 3
D. 1, 2, 3, 4
2, 3, 4, 1
3, 4, 1, 2
4, 1, 2, 3




24.

What will be the output of the program ?

#include
int main()
{
void fun(int, int[]);
int arr[] = {1, 2, 3, 4};
int i; fun(4, arr);
for(i=0; i<4; i++)
printf("%d,", arr[i]);
return 0;
}
void fun(int n, int arr[])
{
int *p=0; int i=0;
while(i++ < n) p = &arr[i];
*p=0;
}

A. 2, 3, 4, 5 B. 1, 2, 3, 4
C. 0, 1, 2, 3 D. 3, 2, 1 0




« previous

1

2

3

4

5

6

7

8

9

...

next »

 
 
 



© 2013 freshersindia.in ® | Copyrights | Terms & Conditions
   Designed by Freshers India
Catch Us on