# C Arrays Questions

Hello PrepSter,

If you find any errors in the quiz below kindly comment in the comment section and we will make it our priority to fix it.

Also if you have a better of the solution to the questions, please do comment them below and if we find it better than ours, we will post it in our website.

Question 1

Time: 00:00:00
What happens if we initialize an array like this

`int array[50] = {5,6,2,1,[15]=18,19,5}; ?`

This means array[0]=5,array[1]=6,array[2]=2,array[3]=1,array[15]=18,array[6]=19,array[7]=5. And the rest of the elements will have a value of 0.

This means array[0]=5,array[1]=6,array[2]=2,array[3]=1,array[15]=18,array[6]=19,array[7]=5. And the rest of the elements will have a value of 0.

This means array[0]=5,array[1]=6,array[2]=2,array[3]=1,array[15]=18,array[16]=19,array[17]=5. And the rest of the elements will have a value of 0.

This means array[0]=5,array[1]=6,array[2]=2,array[3]=1,array[15]=18,array[16]=19,array[17]=5. And the rest of the elements will have a value of 0.

This means array[0]=5,array[1]=6,array[2]=2,array[3]=1,array[15]=18,array[16]=19,array[17]=5. And the rest of the elements will have a null value.

This means array[0]=5,array[1]=6,array[2]=2,array[3]=1,array[15]=18,array[16]=19,array[17]=5. And the rest of the elements will have a null value.

This will give a compilation error because this is not the correct way to initialize an array.

This will give a compilation error because this is not the correct way to initialize an array.

Once you attempt the question then PrepInsta explanation will be displayed.

Start

Question 2

Time: 00:00:00
The given function is used to find out the greatest integer in an array arr of size n where the size of the array is greater 0. What should be the statement inside the while loop ?
```int maxi(int *arr, int n)
{
int x=0, y=n-1;
while (__________)
{
if (p[x] <= p[y])
{
x = x+1;
}
else
{
y = y-1;
}
}
return p[x];
}```

y>(n-1)

y>(n-1)

(n--)>0

(n--)>0

y>x++

y>x++

y!=x

y!=x

Once you attempt the question then PrepInsta explanation will be displayed.

Start

Question 3

Time: 00:00:00
What will be printed after the execution of this program ?

```#include <stdio.h>
int main ()
{
char a [5] = "kamli";
int i, j;
for(i=0,j=5 ; i<j ; a[++i]=a[--j])
printf ("%c ", a[i]);
return 0;
}```

k a m

k a m

i l m

i l m

k i l

k i l

k i m

k i m

Once you attempt the question then PrepInsta explanation will be displayed.

Start

Question 4

Time: 00:00:00
Select the correct output of the following C code.

```#include <stdio.h>
int main ()
{
int x, y;
int a [8] = {1, 2, 3, 4, 5, 6, 7, 8};
for(x = 0; x < 3; x++)
{
a[x] = a[x] + 1; x++;
}
x--;
for (y = 7; y > 4; y--)
{
int x = y/2;
a[x] = a[x] - 1;
}
printf ("%d, %d", x, a[x]);
return 0;
}```

4,4

4,4

3,2

3,2

2,3

2,3

3,3

3,3

Once you attempt the question then PrepInsta explanation will be displayed.

Start

Question 5

Time: 00:00:00
What will be printed by the given program ?

```#include <stdio.h>
int main ()
{
int i, j;
char a[2][3] = {{'x', 'y', 'z'}, {'a', 'b', 'c'}};
char b [3] [2];
char *p = *b;
for (i = 0; i < 2; i++)
{
for (j = 0; j < 3; j++)
{
*(p + 2*j + i) = a [i] [j];
}
}
int k,l;
for(k=0;k<3;k++)
{
for(l=0;l<2;l++)
{
printf("%c ",b[k][l]);
}
printf("\n");
}
return 0;
}```

x y | z a | b c

x y | z a | b c

x a | y b | z c

x a | y b | z c

x c | y b | z a

x c | y b | z a

x b | a z | y c

x b | a z | y c

Once you attempt the question then PrepInsta explanation will be displayed.

Start

Question 6

Time: 00:00:00
What is the correct output of the given program?
```#include<stdio.h>
int n=4;
int arr[n];
int main()
{
arr[2]=8;
if(arr)
printf("Initialized to zero");
else
printf("Not initialized to zero");
return 0;
}```

Initialized to zero.

Initialized to zero.

Not initialized to zero.

Not initialized to zero.

Compilation error.

Compilation error.

Once you attempt the question then PrepInsta explanation will be displayed.

Start

Question 7

Time: 00:00:00
How many more steps needs to be performed after the 7 has been swapped while using insertion sort in the given array {13,2,5,3,9,7,11,8,6,10}

5

5

3

3

1

1

4

4

Once you attempt the question then PrepInsta explanation will be displayed.

Start

Question 8

Time: 00:00:00
Say we have an array arr[n]={1,0,0,1,0,1,1,1,0,...upto n} and a function OR(i, j) which returns the bitwise or on to two bits passed, how many times would one has to use the OR function to find out which index value has 0 or 1.

n times

n times

n*(n-1)/2 times

n*(n-1)/2 times

n/2 times

n/2 times

n-1 times

n-1 times

Once you attempt the question then PrepInsta explanation will be displayed.

Start

Question 9

Time: 00:00:00
For a 3-D array arr[-2...2][1..15][-5...5], how many elements can be stored in arr ?

880

880

600

600

825

825

675

675

Once you attempt the question then PrepInsta explanation will be displayed.

Start

Question 10

Time: 00:00:00
Given an array which is both 2-ordered and 3-ordered and having 2N elements, how many positions away can an element be from it's position if the array were 1-ordered ?

(N-1)/2

(N-1)/2

N/2

N/2

2

2

1

1

Once you attempt the question then PrepInsta explanation will be displayed.