Data Structure Arrays Interview Preparation Guide
Sharpen your Arrays interview expertise with our handpicked 31 questions. These questions are specifically selected to challenge and enhance your knowledge in Arrays. Perfect for all proficiency levels, they are key to your interview success. Get the free PDF download to access all 31 questions and excel in your Arrays interview. This comprehensive guide is essential for effective study and confidence building.31 Arrays Questions and Answers:
1 :: What is Array?
An array is a series of elements. These elements are of the same type. Each element can be individually accessed using an index. For e.g an array of integers. Array elements are stored one after another (contiguous) in the memory. An array can have more than one dimension. First element in an array starts with 0.
2 :: What is two-dimensional array?
An array with two dimensions is called as a two-dimensional array. It is also called as a matrix. In C, a two dimensional array is initialized as int arr[nb_of_rows] [nb_of_columns]. Hence, two dimensional arrays can be considered as a grid. An element in a two dimensional can be accessed by mentioning its row and column. If the array has 20 integer values, it will occupy 80 bytes in memory (assuming 4 bytes for an integer). All of the bytes are in consecutive memory locations, the first row occupying the first 20 bytes, the second the next 20, and so on.
3 :: Explain Array of pointers?
An array of pointers is an array consisting of pointers. Here, each pointer points to a row of the matrix or an element. E.g char *array [] = {“a”, “b”}. This is an array of pointers to to characters.
4 :: What will be output if you will execute following c code?
#include<stdio.h>
void main(){
char arr[7]="Network";
printf("%s",arr);
Garbage value.
5 :: What will be output if you will execute following c code?
#include<stdio.h>
void main(){
char arr[11]="The African Queen";
printf("%s",arr);
null.
6 :: What will be output if you will execute following c code?
#include<stdio.h>
void main(){
char arr[20]="MysticRiver";
printf("%d",sizeof(arr));
20
7 :: What will be output if you will execute following c code?
#include<stdio.h>
void main(){
int const SIZE=5;
int expr;
double value[SIZE]={2.0,4.0,6.0,8.0,10.0};
expr=1|2|3|4;
printf("%f",value[expr]);
Compilation error
8 :: What will be output if you will execute following c code?
#include<stdio.h>
enum power{
Dalai,
Vladimir=3,
Barack,
Hillary
};
void main(){
float leader[Dalai+Hillary]={1.f,2.f,3.f,4.f,5.f};
enum power p=Barack;
printf("%0.f",leader[p>>1+1]);
2
9 :: What will be output if you will execute following c code?
#include<stdio.h>
#define var 3
void main(){
char *cricket[var+~0]={"clarke","kallis"};
char *ptr=cricket[1+~0];
printf("%c",*++ptr);
l
10 :: What will be output if you will execute following c code?
#include<stdio.h>
#define var 3
void main(){
char data[2][3][2]={0,1,2,3,4,5,6,7,8,9,10,11};
printf("%o",data[0][2][1]);
5