Array MCQ Quiz in తెలుగు - Objective Question with Answer for Array - ముఫ్త్ [PDF] డౌన్లోడ్ కరెన్
Last updated on Mar 24, 2025
Latest Array MCQ Objective Questions
Top Array MCQ Objective Questions
Array Question 1:
Consider arr [ ] is an array in C language. What will be the effect of "arr++;" ?
Answer (Detailed Solution Below)
Array Question 1 Detailed Solution
Answer: Option 4
Explanation:
Consider the following example
#include int main() { int arr[10] = {1, 2, 3, 4, 5, 6, 7};
arr++;
return 0;
}
Here arr++; mean that
arr = arr + 1 ;
which is wrong we can not change the base address of an array and it will generate an error.
another way to do that is by using pointers.
#include int main() { int arr[10] = {1, 2, 3, 4, 5, 6, 7};
int *p = arr;
p++;
return 0;
}
Here int *p = arr; new pointer variable will be created which will start pointing to the first element of the array.
and p++; will cause the pointer to start pointing to the next element of the array.
Array Question 2:
Consider the following ANSI C program.
#include
int main()
{
int arr[4][5];
int i, j;
for(i =0; i
{
for (j =0; j
{
arr [i][j] = 10 * i + j;
}
}
print("%d", *(arr[1] + 9));
return 0;
}
What is the output of the above program?
Answer (Detailed Solution Below)
Array Question 2 Detailed Solution
code:
#include
int main(){
int arr[4][5];
int i, j;
for(i =0; i
for (j =0; j
arr [i][j] = 10 +i + j;
}
}
print("%d", *(arr[1] + 9));
return 0;
}
Key Points
- C doesn't check array boundaries. A segmentation fault will only occur if you try to dereference a pointer to memory that your program doesn't have permission to access. Simply going past the end of an array is unlikely to cause that behavior. Undefined behavior is just that - undefined. It may appear to work just fine, but you shouldn't be relying on its safety.
- Your program causes undefined behavior by accessing memory past the end of the array. In this case, it looks like one of your str[i] = c writes overwrite the value in i.
Explanation:
*(arr[1] + 9) can be written as arr[1][9].
as C doesn't follow bound check and follow the row major ordering
arr[1][5] = arr[2][0] / arr[1][4] will be first row of array and then arr[2][0] will be second row of array
arr[1][6] = arr[2][1]
arr[1][7] = arr[2][2]
arr[1][8] = arr[2][3]
arr[1][9] = arr[2][4]
arr[2][4] = 10*i + j = 10*2+4 = 24
Option 4 is the answer.
Array Question 3:
Consider the following declaration of an array in ‘C’ language:
int A[6] = {1, 2, 3, 5};
Which of the following statements is true?
Answer (Detailed Solution Below)
Array Question 3 Detailed Solution
Concept:
An array is a data structure that contains a group of elements. These elements are all of the same data type, such as an integer.
To access element from an array subscript(index) and array name is required
Explanation:
Array name: A
index |
0 |
1 |
2 |
3 |
element |
1 |
2 |
3 |
5 |
To access 3rd element in an array A[2] or 2[A] is used. Therefore Both A[2] and 2[A] represent the value 3
Important point:
A[0] represent the value 1st element
Array Question 4:
Consider the following C program segment.
#include
int main()
{
char s1[7] = "1234";
char *p;
p = s1 + 2;
*p = '0';
printf("%s", s1);
return 0;
}
What will be printed by the program?
Answer (Detailed Solution Below)
Array Question 4 Detailed Solution
Where \0 is a null character
After *p = '0'; \\s1[2] = '0'
100 101 102 103 104
1 |
2 |
0 |
4 |
\0 |
printf(“%s”, s1) will print all starting from address location 100 until the null character.
Output: 1204
Array Question 5:
The largest element of an array index is called ______
Answer (Detailed Solution Below)
Array Question 5 Detailed Solution
Answer: Option 4
Explanation:
The upper bound:
The largest index is called upper bound of the array.
The lower bound:
The smallest index is called lower bound of the array.
Range of Array:
the range of smallest element to largest index is called range of the array.
Array Question 6:
Consider a 1-D array in which the index starts from 2 and ends at 153. The address of index 2 is 1100 and each data in the array takes 4 words. What is the address of A[125] where 125 is the index?
Answer (Detailed Solution Below) 1592
Array Question 6 Detailed Solution
Data:
base address = 1100
starting index = 2
index = 125
size of element = 4 word
Formula:
Array index starts with 0:
Address of array location : base address + index × size of data
Array index starts with 2:
Address of array location : base address + (index - 2) ×size of data
Calculation
Address of A[125] = 1100 + (125 - 2) × 4
= 1100 + 123 × 4
= 1592
Array Question 7:
Consider the following array declaration in the 'C' language:
int array 1[] = {2, 3};
int array2[3]={9};
What will be the output of the following print statement?
printf(“%d, %d”, array1 [1], array2 [2]);
Answer (Detailed Solution Below)
Array Question 7 Detailed Solution
Key Points
An array is defined as the collection of similar types of data items stored at contiguous memory locations. Arrays are the derived data type in C programming language which can store the primitive type of data such as int, char, double, float, etc. C array is beneficial if you have to store similar elements.
Array can be access i th index at array A,
A[ i ]= i [ A ] = *(A+ i) = *(i + A)
Given that,
int array1[ ] = {2, 3);
int array2[ 3 ] = {9};
printf(“%d, %d”, array1[1], 2[array2]);
array1 is dynamic allocation of {2,3}.
array2 is three memory cells and stores 9 at 0th index of array2.
printf(“%d, %d”, array1[1], 2[array2]);
array1[1]= 1st index at array1 = 3
array2 [2]= 2nd index at array2 = 0
Hence the correct answer is 3, 0.
Array Question 8:
Consider the statement.
int val[2] [4] = {1, 2, 3, 4, 5, 6, 7, 8}; 4 will be the value of
Answer (Detailed Solution Below)
Array Question 8 Detailed Solution
Concept:
val[2][4] is the two-dimensional array representation with 2 rows and 4 columns
rang of rows : 0 to 1
rand of columns = 0 to 3
Explanation:
val[0][0] = 1 |
val[0][1] = 2 |
val[0][2] = 3 | val[0][3] =4 |
val[1][0] = 5 |
val[1][1] = 6 |
val[1][2] = 7 | val[1][3] = 8 |
Hence the correct answer is Option 4
Array Question 9:
Consider a two dimensional array X[-10…5, 7….15] in which staring location is at 250. If every data of given array takes 4 byte of space and store in column major order, then what will be the location of A[2][10]
Answer (Detailed Solution Below) 490
Array Question 9 Detailed Solution
The correct answer is 490.
Concepts:
Array:
An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type.
Explanation:
The given data,
Range of given array: [-10...5,7......15]
A[2][10]= ?
A[-10][7] = 250= starting location = base location of the array.
b= base of the index= starting index.
u= upper of the index= upper index.
r1= (u1-b1+1)= column size= number of rows
r1=(u2-b2+1) =row size= number of columns
Number of rows
r1 =5 – (–10) + 1= 16
Number of columns:
r2= 15 – 7 + 1 = 9
Array size: A16 x 9
Formula:
Row major order:
A[i][j] = base location of the array+ {( i - b1 ) r2 + ( j - b2) } x c
Column major order:
A[i][j] = base location of the array+ {( j - b2 ) r1 + (i - b1) } x c
where is c = count = size of each element.
Calculation:
column-major order
A[i][j] = base location of the array+ {( j - b2 )r1+ (i-b1) } x c
c = 4
A[2][10] = 250 + {(10 - 7)16 + (2- (- 10)) } x 4
A[2][10] = 250 + {(3)16 +12 } x 4
A[2][10] = 250 + {48 +12 } x 4
A[2][10] = 250 + 240
A[2][10] = 490
Hence the correct answer is 490.
Array Question 10:
Find the number of elements in the following array.
float f [6] [4] [2];
Answer (Detailed Solution Below)
Array Question 10 Detailed Solution
Explanation:-
A number of elements present in the array can be found by calculating the length of the array.
Algorithm:
Step 1: Start
Step 2: Initialize arr[] = {1, 2, 3, 4, 5, 6}
Step 3: length = sizeof(arr) / sizeof(arr[0])
Step 4: Print "number of elements present in given array" by assigning length.
Step 5: Return 0
Step 6: End
Analysis:- float f [6] [4] [2]
Number of element = 6 × 4 × 2 = 48.
So, the number of elements in the array, float f [6] [4] [2] is 48.
Additional Information
Arrays:- An array is a group of same-typed variables that is referred to by a common name. And each data item is called an element of the array. The data types of the elements may be any valid data type like char, int, float, etc.
The following figure shows how the array stores values sequentially: