C Arrays Questions 2

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
A 1=D array  Arr has 80 indices where each elements is a string value having a memory space of 4 memory words. If the starting address of the array is 850 then what is the starting address of Arr[55].

1066

1066

1070

1070

1080

1080

1120

1120

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

Please login to submit your explanation

Start

Question 2

Time: 00:00:00
Select the correct option for the following C program.
#include<stdio.h> 
void make(int n)
{
int i;
int a[n] = {0};
int b[n];
for (i=0; i<n; i++)
b[i] = 0;
}
int main()
{
make(4);
return 0;
}

The definition of the arrays is incorrect resulting in compiler error.

The definition of the arrays is incorrect resulting in compiler error.

Initialization of a is incorrect because they can't be initialized at the time of their definition.

Initialization of a is incorrect because they can't be initialized at the time of their definition.

Both definition and initialization of the array is incorrect.

Both definition and initialization of the array is incorrect.

There is no compiler error. Both the array are initialized to 0.

There is no compiler error. Both the array are initialized to 0.

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

Please login to submit your explanation

Start

Question 3

Time: 00:00:00
What is the correct output of the following code ?
#include <stdio.h> 
int main ()
{
char a [5] = "kamli";
int i, j;
for (i = 0, j = 5; i < j)
{
a[i++] = a[j--]);
printf ("%s ", a);
}
return 0;
}

k i l

k i l

i l m

i l m

k a m

k a m

(null)

(null)

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

Please login to submit your explanation

Start

Question 4

Time: 00:00:00
If the given base address of an array is 850 and the integer size is 16 bits. Then what will be printed after the execution of the given code?
#include <stdio.h> 
int main()
{
int arr[5];
arr++;
printf("%u", arr);
return 0;
}

866

866

865

865

error : lvalue required.

error : lvalue required.

zero

zero

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

Please login to submit your explanation

Start

Question 5

Time: 00:00:00
What will be printed by the end of this program ?
#include<stdio.h> 
int lo(int);
int main()
{
int arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
int n = sizeof(arr)/sizeof(arr[0]);
int i;
printf("%d ",sizeof (arr));
lo(arr);
return 0;
}
int lo(int a[])
{
printf("%d",sizeof (a));
return 0;
}

12 12

12 12

12 8

12 8

8 8

8 8

48 8

48 8

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

Please login to submit your explanation

Start

Question 6

Time: 00:00:00
Choose the correct output for the following code.
#include<stdio.h> 
int main()
{
int arr[] = {1, 2, 3, 4, 5, 6, 7, 8};
int *i = (int*)(&arr+1);
printf("%d", *(i-1) );
return 0;
}

9

9

Garbage value

Garbage value

1 2

1 2

8

8

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

Please login to submit your explanation

Start

Question 7

Time: 00:00:00
Consider the following declaration of a ‘two-dimensional array in C:

char arr[100][100]

If the starting address of the array is 0 then what is address of arr[20][30]

2030

2030

2020

2020

600

600

599

599

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

Please login to submit your explanation

Start

Question 8

Time: 00:00:00
Select the option that is true about arrays.

When an array is passed to a function, C compiler creates a copy of array

When an array is passed to a function, C compiler creates a copy of array

For every type T except void and function type, there can be an array of T.

For every type T except void and function type, there can be an array of T.

2D arrays are stored in column major form

2D arrays are stored in column major form

For every type T, there can be an array of T.

For every type T, there can be an array of T.

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

Please login to submit your explanation

Start

Question 9

Time: 00:00:00
What will be printed by the following program ?
#include<stdio.h> 
int main()
{
int i;
int a[5] = {1};
for (i = 0; i < 5; i++)
printf("%d ", a[i]);
return 0;
}

1 1 1 1 1

1 1 1 1 1

1 followed by garbage value

1 followed by garbage value

1

1

1 0 0 0 0

1 0 0 0 0

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

Please login to submit your explanation

Start

Question 10

Time: 00:00:00
Assuming that the starting address of the array is 2000 and integer size is 32.
#include <stdio.h> 
int main()
{
int arr[5];
printf("%u %u", arr + 1, &arr + 1);
return 0;
}

2001 2033

2001 2033

2002 2033

2002 2033

2004 2020

2004 2020

2004 2032

2004 2032

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

Please login to submit your explanation

Start

["0","40","60","80","100"]
["Need more practice!","Keep trying!","Not bad!","Good work!","Perfect!"]

Hey ! Follow us on G+