Arrays in C Programming - Objective Type Questions with Answers | Arrays MCQs

Sports GK Questions and Answers 2024 (Latest Updated)

Awards & Honours GK Questions 2024 (Latest Updated)

Questions
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 9
D 11

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[2][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: Option [D]
Advertisement
Article and Schedule Quiz Start Test!
DOWNLOAD CURRENT AFFAIRS PDF FROM APP
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: 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

mcq on c programming array 03

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: 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: Option [C]

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

Chapters

Assam Direct Recruitment Test Series

Computer Science Topics