0% found this document useful (0 votes)
601 views12 pages

Array MCQ

The document contains several questions and answers related to arrays in C programming. It addresses topics like: 1) Declaring an array without specifying its size and initializing it with values between braces. 2) Whether it is correct to initialize an array of a specified size with more elements than its size. 3) What a multidimensional array of dimension N contains. 4) The output of sample code accessing elements of a 1D and 2D array. 5) How elements are stored in memory for a 2D array and calculating the address of a specific element.

Uploaded by

Garima
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)
601 views12 pages

Array MCQ

The document contains several questions and answers related to arrays in C programming. It addresses topics like: 1) Declaring an array without specifying its size and initializing it with values between braces. 2) Whether it is correct to initialize an array of a specified size with more elements than its size. 3) What a multidimensional array of dimension N contains. 4) The output of sample code accessing elements of a 1D and 2D array. 5) How elements are stored in memory for a 2D array and calculating the address of a specific element.

Uploaded by

Garima
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/ 12

Question

We can declare an array without declare it size?


Like int n[] = { 2, 4, 12, 5, 45, 5 } ;
1. True
2. False
Question

We can declare an array without declare it size?


Like int n[] = { 2, 4, 12, 5, 45, 5 } ;
1. True
2. False

Answer: True
Question

int num[6] = { 2, 4, 12, 5, 45, 5, 7 } ; Is correct?


1. True
2. False
Question

int num[6] = { 2, 4, 12, 5, 45, 5, 7 } ; Is correct?


1. True
2. False

Answer: False
Question

A multidimensional array of dimension N is a collection of?


1. Single dimension array
2. N dimensional arrays
3. N-1 dimensional arrays
4. N-2 dimensional arrays
Question

A multidimensional array of dimension N is a collection of?


1. Single dimension array
2. N dimensional arrays
3. N-1 dimensional arrays
4. N-2 dimensional arrays

Answer: 3
Question

What is the output of the following program ?

1. 15
2. 00
3. Compiler error
4. None of the above
Question

What is the output of the following program ?

1. 1 5
2. 0 0
3. Compiler error
4. None of the above
Answer: 4
You are accessing -1 index and 4 index which is outside the limit 0 to 2.
You get only garbage values.
Question

Consider the following declaration of a ‘two-dimensional array


in C: char a[100][100]; Assuming that the main memory is
byte-addressable and that the array is stored starting from
memory address 0, the address of a[50][60]is
1. 5060
2. 5050
3. 6060
4. 6500
Question

Consider the following declaration of a ‘two-dimensional array


in C: char a[100][100]; Assuming that the main memory is
byte-addressable and that the array is stored starting from
memory address 0, the address of a[50][60]is
1. 5060
2. 5050
3. 6060
4. 6500

Answer: A
Row major ordering
Question

What is the output of the following program?

1. 2
2. 3
3. 4
4. 5
Question

What is the output of the following program?

1. 2
2. 3
3. 4
4. 5
Answer: Option 4 : 5

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy