0% found this document useful (0 votes)
299 views3 pages

1 C Programming Arrays Download PDF

The document contains 5 multiple choice questions about arrays in C programming. It tests concepts like declaring and initializing multi-dimensional arrays, accessing array elements using pointers and indexes, and default initialization of array elements. For each question, the correct answer is provided along with a short explanation.

Uploaded by

NAGARAJAN S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
299 views3 pages

1 C Programming Arrays Download PDF

The document contains 5 multiple choice questions about arrays in C programming. It tests concepts like declaring and initializing multi-dimensional arrays, accessing array elements using pointers and indexes, and default initialization of array elements. For each question, the correct answer is provided along with a short explanation.

Uploaded by

NAGARAJAN S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

gkseries.

com
http://www.gkseries.com/computer-engineering/c-programming/arrays/c-programming-objective-questions-and-answers-on-arrays

Arrays in C Programming - Objective Type Questions with


Answers

1.

int warr[3][2][2]={1,2,3,4,5,6,7,8,9,10,11,12};

What will be the value of warr[2][1][0]?

[A] 5

[B] 7

[C] 7

[D] 11

Answer & Explanation

Answer: Option [D]

Let us identify the arrays for each values.

warr[0][0][0]=1

warr[0][0][1]=2

warr[0][1][0]=3

warr[0][1][1]=4

warr[1][0][0]=5

warr[1][0][1]=6

warr[1][1][0]=7

warr[1][1][1]=8

warr[2][0][0]=9

warr[2][0][1]=10

warr[0][1][0]=11

2.

Given the piece of code

int a[50];
int *pa;
pa=a;
To access the 6th element of the array which of the following is incorrect?

[A] *(a+5)

[B] a[5]

[C] pa[5]

[D] *(*pa+5)

Answer & Explanation

Answer: Option [D]

3.

What will be the output of the following code segment?

int a[10]={1,2,3,4,5,6,7,8,9,10};
*p=a;
printf("\n%d:%d", p[7], p[a[7]]);

[A] 7:7

[B] 7:8

[C] 8:9

[D] 8:8

Answer & Explanation

Answer: Option [C]

The first element of the array i.e. a[0] is assigned by *p=a. Therefore a[0]=1. Then p[7]=8 and p[a[7]]=p[8]=9

Hence 8:9
4.

What is the effect of the following code?

main()
{
int a[4]={1,5};
printf("%d",a[3]);
}

[A] 0

[B] Syntax error because of improper


initialization

[C] 5

[D] Syntax error because of invalid


index

Answer & Explanation

Answer: Option [A]

Given that int a[4]={1,5}

So a[2], a[3] etc. are 0

5.

For the following definition, which of the given option is correct?

int a[10];

[A] a++;

[B] a=a+1

[C] *a++

[D] *a[1]

Answer & Explanation

Answer: Option [C]

*a+0 points to the a[0] location.

You might also like