Array MCQ - General Knowledge Question and Answer

# Array MCQ - Question and Answer

In this Chapter, we are going to discuss some questions related to array

#### 1. Let A be a dimensional array declared as follows A:[1....10][1.....15] of integers. Assume that each integer takes one memory location, the array is stored in row-major order and the first element of the array is stored at location 100, what is the address of the element A[i][j]?

15i+j+84
15j+i+84
10i+j+98
d. None of the above

15i+j+84

#### Faster access to non-local variables is achieved using an array of pointers to activation record called a

heap
activation tree
display
stack

Faster access to non-local variables is achieved using an array of pointer to activation records called a display

*(s+2)
s+3
*(s+3) + 5
*(s+3) + 2

*(s+2)

n(n-1)
n2 (n-1)
n(n+1)
n(n+2)

n(n+2)

#### Suppose we want to arrange n numbers stored in an array such that all negative values occur such before all positive ones. Minimum number of exchange required in the worst case

n-1
n
n+1
none of the above

n-1

1
2
3
8

NO Eaplanation

#### If an array is declared as arr[] = {1,3,5,7,9}; then what is the value of arr[3] ?

1
7
9
5

in index 3 the value 7 is present

50
100
200
400

400

49
50
51
0

50

5
25
10
0

25

*(arr+i)
*(i + arr)
arr[i]
All of these

All of these

PPPXXXYYYZZZ
XPPPXXYYYZZZ
XXXYYYZZZPPP
XXXYYYZZZPPPX

XPPPXXYYYZZZ

XXYZ
XXXYYZZ
XXXYZZ
XXXYZZX

XXXYZZ

world
programming
welcome
none of these

world

ctype.h
stdio.h
string.h
math.h

string.h

gets()
scanf()
getchar()
all of these

all of these

XXABYYZZZ
XABYYYZZZ
ABXXXYYYZZ
ABXXXYYYZZZ

XXABYYZZZ

5
6
7
8

7

#### s1 = “HI”, s2 = “HELLO”, s3 = “BYE”. How can we concatenate the three strings?

strcat(s1,s2,s3)
strcat(s1(strcat(s2,s3)))
strcpy(s1, strcat(s2,s3))
strcpy(s2, strcat(s2,s3))

strcat(s1(strcat(s2,s3)))

22
23
24
25

23

strcat()
strtok()
strcpy()

strcat()

Array
String
Structure
All of these

All of these

Array
String
Structure
All of these

Structure

#### Memory for a structure is allocated at the time of

Structure definition
Structure variable declaration
Structure declaration
Function declaration

Structure variable declaration

Dot operator
Comma operator
Ternary operator

Dot operator

#### A structure that can be placed within another structure is known as

Self-referential structure
Nested structure
Parallel structure
Pointer to structure

Nested structure

Dot operator
Comma operator
Ternary operator

Dot operator

struct
union
enum
all of these