Professional Documents
Culture Documents
001 Chapter8-Arrays
001 Chapter8-Arrays
CHAPTER
Data Structures
ARRAYS
Syllabus
Introduction to data structure, primitive and non-primitive data structure, linear and non-linear
structure, static and dynamic data structure.
Arrays : One and two Dimensional arrays : Sequential allocation and address calculation;
One dimensional array : Traversal, Searching (Linear, Binary Search), Insertion of an element in
an array, deletion of an element from an array, Sorting (Insertion, Se lection)
Two-dimensional arrays : Traversal Finding suml difference of two NxM arrays containing
numeric values, Interchanging Row and Column elements in a two dimensional array;
TOPIC-1
Data Structures and One-dimensional Arrays
TOPIC - 1
Data Structures and One-dimensional
Arrays
Quick Review TOPIC - 2
1. Introduction
A data structure is a named group of data of different data types which can be processed as a single unit. In other
words, a data structure is a logical method of representing data in memory using simple and complex data types
provided by the language.
Organized collection of data is called data structure.
The data structure can be classified into following two types :
A. Simple Data Structure: These are build from fundamental data types i.e., int, float, char etc.
Example: Array, Structure
B. Compound Data Structure: Simple data structure can be combined in various ways to form more complex
structure called compound data structures. It is of two types:
(i) Linear Data Structure: A data structure is said to be linear if its elements or items are stored sequentially.
Example: Stack, Queue, Linked List.
(ii) Non-Linear Data Structure: These are multilevel data structure, in which elements are not stored
sequentially. Example: Tree, Graph.
Data Structure
EduSuccess Smart Learning Centers I www.edusuccess.in I Contact # +91- 85 0606 1616 / 5252
LEARNING CENTERS FOR CLASSES VI -XII EduSuccess : Delhi's #1 Tuition Center for Computer Science, Class — 12
2. Arrays
It is a collection of similar type of data elements. Its elements are allocated in continuous memory. Arrays are of
different types:
(i) One-dimensional array
(ii) Two-dimensional array
(i) One Dimensional Array : The simplest form of an array is one-dimensional array. The array itself is given a
name and its elements are referred to by their subscripts. The notation of array can be:
Array_name [lower bound L, upper bound U]
In C+ +, its like
Arrayname [size ]
where, size specifies the number of elements in the array and the subscript (index) value ranges
from 0 through size-1.
Length of the array = U - L + 1
Address of element with subscript I = B + S*(I-L)
where,
B : Base Address (Address of the very first element)
S : Size of an array element
L : Lower Bound of array
Basic Operations on 1-D Array :
1. Traversal : Visiting each element (from start to end) is called traversal.
2. Searching : Searching in a 1-D array can be done in following two ways: (i) Linear Search, (ii) Binary search
Linear Search : In linear search (sequential search), each element of the array is compared with given item
to be searched for, one by one. This searching te chnique can work for both unsorted and sorted array.
(ii) Binary Search : The binary search technique can work only for sorted arrays. To search an element say
ITEM, in a sorted array (suppose in ascending order), the ITEM is compared with the middle element.
If the ITEM is greater than the middle element, second half of the array becomes new segment to be
scanned, when an ITEM is less than middle element, first half becomes the new segment to be scanned.
The same process is repeated until the ITEM is found or the segment is reduced to the single element
and if still ITEM is not found.
3. Insertion : Insertion of new element can be done at a specific position and if the array is sorted, insertion of
the element will be at appropriate place. Insertion is not possible, if the array is already full which is called
"OVERFLOW" but replacement of an existing element is possible.
4. Deletion : Deletion of an element means its removal from the array. Deletion may not be possible if the
element does not exist. Deletion can be done in any one of the following ways:
0 Deletion of an element from a specific position.
(ii) Deletion of an element from an unsorted array.
(iii) Deletion of an element from a sorted array.
5. Sorting : Sorting means arranging the elements in some specific order, i.e., either ascending or descending
order. The various sorting techniques available are :
(i) Insertion Sort : Initially, the first element is assumed to be sorted. In the first pass, 2nd element is
inserted into its proper place in the sorted part of the array. Similarly, in the next pass, the 3rd element is
placed and so on. Given below is the insertion sort for ascending order.
Array at beginning : 42 29 74 11 65 58
After Pass 1 29 42 74 11 65 58
After pass 2 29 42 74 11 65 58
After pass 3 11 29 42 74 65 58
After pass 4 11 29 42 65 74 58
After pass 5 11 29 42 58 65 74
Sorted Array 11 29 42 58 65 74
EduSuccess Smart Learning Centers I www.edusuccess.in I Contact # +91- 85 0606 1616 / 5252
AR RAYS LEARNING CENTERS FOR CLASSES VI -XII
a [j+1] =temp;
cout«"\n After pass" «i;
for (k=0; k<n; k++)
cout«a[k];
}
(ii) Selection Sort : The element with the smallest value (if found) is swapped with the first element. As a
result of this interchange, the smallest element is placed in the 1st position of the array. In the second
pass, second smallest element is searched and swapped with second element and so on. Given below is
the selection sort for ascending order.
Array at beginning : 42 29 74 11 65 58
After Pass 1 11 29 74 42 65 58
After pass 2 11 29 74 42 65 58
After pass 3 11 29 42 74 65 58
After pass 4 11 29 42 58 65 74
After pass 5 11 29 42 58 65 74
Sorted Array 11 29 42 58 65 74
//function for Selection Sort
void SelectionSort (int a[], int n)
{ int i, small, pos, temp;
for (i = 0; i<n; i++)
small=a[i];
pos=i;
for (j=i+1; j<n; j++)
{ if (a[j]<small)
small=a [j ;
Pos=j ; }
}
temp = a[i];
a[i]=a[pos];
a [pos] =temp;
cout«"\n After Pass" «i+1;
for (j=0; j<n; j++)
cout«a[j];
}
(iii) Bubble Sort : In this technique, two adjacent values are compared and they are exchanged, if not in
proper order. In every pass, the larger element settles at its appropriate position in the bottom. Given
below is the bubble sort for ascending order.
Array at beginning: 42 29 74 11 65 58
After Pass 1 29 42 11 65 58 74
After pass 2 29 11 42 58 65 74
After pass 3 11 29 42 58 65 74
After pass 4 11 29 42 58 65 74
After pass 5 11 29 42 58 65 74
Sorted Array 11 29 42 58 65 74
//function for Bubble sort
void Bubblesort (int a[ ], int n)
{ int temp;
for (int i=0; i<n; i++)
(for (int j=0; j<n-1; j++)
(if (a[j]>a[j+1])
EduSuccess Smart Learning Centers I www.edusuccess.in I Contact # +91- 85 0606 1616 / 5252
LEARNING CENTERS FOR CLASSES VI -XII EduSuccess : Delhi's #1 Tuition Center for Computer Science, Class - 12
{ te mp = a [j] ;
A[j] =a [j+l];
A[j+1].temp;
}
}
score [], int size) in C+ +, which should check all if (score[i] <40)
the elements of the array and give an increase of score[i].score[i]+5;
5 to those scores which are less than 40. II .
cout«score[i]«"
Example : if an array of seven integers is as }
follows : }
EduSuccess Smart Learning Centers I www.edusuccess.in I Contact # +91- 85 0606 1616 / 5252
ARRAYS LEARNING CENTERS FOR CLASSES VI -XII
Q. 2 Find the output of the following C+ + program : column in the memory. If the element A[20][25]
#include<iostream.h> is stored at 50000, find out the location of A[25]
void repch(char s[]) { [CBSE SQP, 2016] [30]. [Delhi, 2015]
for (int i=0;s[i]!='\0';i++)
{
Ans. A [i] [j ] = B+W x [No. of rows x (I+
(J-Lc)
if (((i%2) ! =0) &&(s[i]!=s[i+1])) A[20] [25] = B + 2x[30x(20-0)+(25-0)]
{
50000 = B+2x[30x(20-0)+(25-0)]
s [1] =‘@/ ; B = 48750
cout«"Hello"; A [7] [10] = 48750+ 2x[30x(7-0)+
}
(10-0) ]
else if (s[i]==s[i+1])
{ = 49190
s[i+1]="!"; [1 mark for writing correct formula or
substitution with correct values]
} [1 mark for calculating correct base address.]
}
[1 mark for calculating correct address of A[7][10].
void main() Q. 5 An array P[30][20] is stored along the column in
{
for (in K = 0; K<N; K++) Q. 6 Write a function to sort any array of n elements
(K%2==0) ?cout«A [K] «"%" cout«A using insertion sort. Array should be passed as
[K] «endl ; argument to the function. [Delhi, 2015]
}
Ans.
void main() int p,ptr; void
{ int H[ //Assuming a[0]=int mini n s e r t s o
10, 5 ; ] = {30, 40, 50, 20,
}
smallest integer rt (int a
[] , int
switchover(H, 6, 3); n)
display(H, 6);
{
40%25
temp=a [p]
[1/2 mark for each value in the above order] p t r =p - l ;
[deduct 1/2 mark for not putting '%' in between while(temp<a[ptr])
values] An integer array A [30] [40] is stored {
EduSuccess Smart Learning Centers I www.edusuccess.in I Contact # +91- 85 0606 1616 / 5252
LEARNING CENTERS FOR CLASSES VI -XII
EduSuccess : Delhi's #1 Tuition Center for Computer Science, Class 12-
[1/2 mark for correct for loop] Ans. void NewMAT (int A [] [] tint r, int c)
{
Q. 8. Write the definition of a function Alter (intA[], int N) in C+ +, which should change all the multiples of 5 in the
array to 5 and rest of the elements as 0. For example, if an array of 10 integers is as follows : [Delhi, 2015]
A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[9]
55 43 20 16 39 90 83 40 48 25
After executing the function, the array content should be changed as follows :
A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[9]
5 0 5 0 0 5 0 5 0 5
Ans. void Alter (int A [] int N)
{
A[i] = 0;
}
OR
Any other correct equivalent function definition
(1/2 Mark for correct loop)
(1/2 Mark for correct checking of divisiblity of array elements by 5)
(1/2 Mark for correct use of else OR correct checking of non divisibility of array elements by 5)
(1/2 Mark for correct assignment of 5 and 0 for multiples and non multiples of 5 respectively)
Q. 9. A two dimensional array P[20] [50] is stored = BaseAddress + 4*255
in the memory along the row with each of its = BaseAddress + 1020
element occupying 4 bytes, find the address of BaseAddress = 15000 - 1020 = 13980
the element P[10] [30], if the element P[5] [5] is
LOC (P [10] [30]) = 13980 + 4* [10 * 50 + 30]
stored at the memory location 15000.
= 13980 + 4 * 530
[Delhi, 2015]
= 13980 + 2120
Ans. Loc (P [I] [J] along the row
= 16100
=BaseAddress+W [(I-LBR) *C+ (J-LBC)]
OR LOC (P [10] [30])
(where C is the number of columns, LBR = LBC
= Loc (P[5] [5]) + W[ (I-LBR) * C+ (J-LBC)]
= 0)
= 15000 + 4 [(10 - 5) * 50 + (30 - 5)]
LOC (P [5][5])
= 15000 + 4 [5 * 50 + 25]
= BaseAddress + W* [I*C + J]
= 15000 + 4 *275
15000 = BaseAddress + 4 * [5 * 50 + 5]
= 15000 + 1100
= BaseAddress + 4 * [250 + 5]
= 16100
EduSuccess Smart Learning Centers I www.edusuccess.in I Contact # +91- 85 0606 1616 / 5252
ARRAYS LEARNING CENTERS FOR CLASSES VI -XII
After executing the function, the array content should be changed as follows : [0.D, 2015]
P[0] P[1] P[2] P[3] P[4] P[5] P[6] P[7] P[8] P[9]
10 1 10 1 1 1 10 10 1 1
OR
Any other correct equivalent function definition
(1/2 Mark for correct loop)
(1/2 Mark for correct checking of divisiblity of array elements by 10)
(1/2 Mark for correct use of else OR correct checking of non divisibility of array elements by 10)
(1/2 Mark for correct assignment of 10 and 1 for multiple and non multiples of 10 respectively)
Q. 11. Write code for a function oddEven (int s[], int N) +, w hich takes integer arrays, each
in C+ +, to add 5 in all the odd values and 10 in
all the even values of the array S.
Example : If the original content of the array S is
50 11 19 24 I 28 containing 6 elements as parameters. The
The modified content will be :
60 16 24 34 I 38
if (s [i] %2 ! =0)
s [i] =s [i] +5; [1] 3rd and 5th) of the two arrays, for example
else
=s [i] +10;
} Q. 12. Write the definition for a function
EduSuccess Smart Learning Centers I www.edusuccess.in I Contact # +91- 85 0606 1616 / 5252
LEARNING CENTERS FOR CLASSES VI -XII EduSuccess : Delhi's #1 Tuition Center for Computer Science, Class - 12
{
Q. 15. Write code for a function void Convert (int T[],
temp=A[i] int Num) in C+ +, which re-positions all the
A[i]=B[i] elements of the array by shifting each of them
B [i] +temp; one to one position before and by shifting the
}
first element to the last position.
} [2] For example : If the content of the array is :
Q. 13 Write a user-defined function DisTen (int A[] [4], 0 1 2 3 4
int N, int M) in C++ to find and display all the 22 25 70 32 12
numbers, which are divisible by 10. For example
if the content of array is : The changed content will be :
12 20 13 0 1 2 3 4
2 10 30 25 70 32 12 22
M) int i, j, temp;
{ for (i=Num; i > 10; i-=1)
int i j ; ,
{
for (i=0; i<M; i++) j = i - 1;
{
temp = P [1] ; [1]
for (j=0; j<N; j++) P [i] = P [j] ;
{
P [j] = temp;
if (A[i] [j]9610-0) }
j=j+1; [1] Q. 17 Write a function Transfer (int A[], int B[J, int
Size) in C+ + to copy the elements of array A
temp = P [i] ;
into array B in such a way that all the negative
P [i] = P[j]; elements of A appear in the beginning of 13,
followed by all the positive elements, followed
EduSuccess Smart Learning Centers I www.edusuccess.in I Contact # +91- 85 0606 1616 / 5252
ARRAYS LEARNING CENTERS FOR CLASSES VI -XII
by all the zeroes maintaining their respective Where C is the number of columns and
orders in array A. For example : LBR=LBC=1
If the contents of array A are : LOC (ARR[10] [5])
7, -23, 3, 0, -8, -3, 4, 0 15000 = BaseAddress + W [(I - I) * C + (J-1)]
The contents of array B should be = BaseAddress + 4 [9*20 + 4]
-23, -8, -3, 7, 3, 4, 0 = BaseAddress + 4[180 + 4]
= BaseAddress + 4 * 184
[CBSE SQP, 2013]
Ans. void Transfer (int A[], int B[], int size) = BaseAddress + 736
{
BaseAddress = 15000 - 736
for (int i = 0; i<size; = 14264
{
= BaseAddress + W [I *C + J] i n t S c o re ;
15000 = BaseAddress + 4 [10 * 20 + 5] ch ar Teamn a me [20 ] ;
= BaseAddress + 4 [200 + 5] );
= BaseAddress + 4 x 205 An s . v o i d S O R T S C O R E ( I P L a [] , i nt n)
= BaseAddress + 820 int largest;
IPL temp ;
BaseAddress = 15000 - 820
= 14180 for ( int K = 0; K < n-1; K++)
{ largest = K;
LOC (ARR [30] [10] ) = 14180 + 4 [30 * 20 + 10] for ( int j = K+1; j < n; j++)
= 14180 + 4 * 610 { if ( a [j] . score > a [largest]
= 14180 + 2440 score)
{ largest = j;
= 16620 }
OR }
= 15000 + 4 [20*20 + 5]
(3 marks for correct program)
= 15000 + 4 *405
= 15000 + 1620 Q. 20 Write a function in C+ + TWOTOONE() which
accepts two array X[ ], Y[ ] and their size n as
= 16620 OR argument. Both the arrays X[ ] and Y[ ] have
EduSuccess Smart Learning Centers I www.edusuccess.in I Contact # +91- 85 0606 1616 / 5252
LEARNING CENTERS FOR CLASSES VI -XII EduSuccess : Delhi's #1 Tuition Center for Computer Science, Class - 12
the same number of elements. Transfer the for (int i=0; i<N; i++)
content from two arrays X[ ], 1([ ] to array Z[ ]. {
int z [n] ; }
[0.D, 20121
}
For example :
(3 marks for correct program)
If the content of array ARR is
Q. 21. Write code for a function void EvenOdd (int T[], 90, 56, 45, 20, 34, 54
int C) in C++, to add 1 in all the odd values and
2 in all the even values of the array T. The content of array ARR should become
Example : If the original content of the array T is 56, 90, 45, 34, 20, 54
T[0] T[1] T[2] T[3] T[4] Ans. void SWAP2BEST (int ARR [] , int Size)
{
35 12 16 69 26
for (int n=0 ; n<size ; n++)
The modified content will be: {
36 14 18 70 28 int temp = 0;
temp = ARR [n] ;
Ans. void EvenOdd(intT int(C) ARR [n] = ARR [n+1] ;
{
(int P [] , int N)
{
EduSuccess Smart Learning Centers I www.edusuccess.in I Contact # +91- 85 0606 1616 / 5252
ARRAYS LEARNING CENTERS FOR CLASSES VI -XII
TOPIC-2
Two-dimensional Arrays
Quick Review
1. Two Dimensional Array
A two dimensional array is an array in which each element is itself an array. Two dimensional arrays are called
matrices. A matrix resembles a table with rows and columns. In C+ +, 2-D array notation is
Arrayname[Row] [Column]
No of elements = Row * Column
columns
[0][0] [0][1] [0][2] [0][3] [0][4]
rows [1][O] [1][1] [1][2] [1][3] [1][4]
2
[ ][O] [2][1] [2][2] [2][3] [2][4]
[3][O] [ 3 ] [ 1 ] [3][2] [3][3] [3][4]
2. Implementation of 2-D array in Memory Elements of a 2-D array in memory are allocated contiguous
locations. The array elements are stored linearly
EduSuccess Smart Learning Centers I www.edusuccess.in I Contact # +91- 85 0606 1616 / 5252
LEARNING CENTERS FOR CLASSES VI -XII EduSuccess : Delhi's #1 Tuition Center for Computer Science, Class 12
-
eh Mark of logic of checking alternate elements) The output should be 49 [Delhi, 20141
Mark for displaying the alternate elements
12 Ans. void SumLast 3 (int A [] [4] , int N,
Q. 2 Write a function in C+ + to print the sum of all int M)
the non-negative elements present on both the {
EduSuccess Smart Learning Centers I www.edusuccess.in I Contact # +91- 85 0606 1616 / 5252
AR RAYS LEARNING CENTERS FOR CLASSES VI -XII
For example :
If the 2D array is If the array is containing:
678 136 793 The following 12 45 67 33 90 76
should be displayed : 21 43 59 The
8 output will be
3 12 67 90 21 59
7 [CBSE Comptt.2014] Ans. void SKIPEACH (int H [ ] [3] , int C,
Ans. void diag (int x [] H , int m, int n) int R)
{
{
}
}
[2]
(2 marks for correct program)
}
Q. 1. An array P[151[10] is stored along the column in Ans. Loc (P[8][5]) = B+W((I-Lr)+ (J-Lc)M)
the memory with each element requiring 4 bytes = 1400 +4((8-0)+ (5-0)15)
of storage. If the base address of array P is 1400,
find out the location of P[8][5]. = 1732. [3]
[Delhi, 2013]
EduSuccess Smart Learning Centers I www.edusuccess.in I Contact # +91- 85 0606 1616 / 5252
LEARNING CENTERS FOR CLASSES VI -XII
EduSuccess : Delhi's #1 Tuition Center for Computer Science, Class - 12
Q. 2 Given an array A[10][12] whose base address is element requiring 2 bytes of storage. If
10000. Calculate the memory location of A[2][5] if the base address of array T is 42000,
each element occupies 4 bytes and array is stored find out the location of T[10][15]. Also,
columnwise. [CBSE Comptt.2014] find the total number of elements present
Ans. w=4 in this array.
b=10000 [Delhi, 2014]
m=10 Ans. Array A[25][20]
n[i][i] = [b+ + m(j-12) Base Address = 42000
n[2][5] = [10000+ 4(2-0) + 10(5-0)] Size of element(W) = 2 bytes
= [10000 +8 +50 ] A[I][J]=A[10][15] hence I=10 and J=15
n[2][5] = 10058 Total Row (R) = 25 [1]
(1 mark for steps) Total Column (C) = 20
Q. 3 An array T[4..35][-2..15] is stored in the memory A [I][J]=B+ W[C(I-0)+ (J-0)]
along the row with each element occupying 4 A[10][15]=42000 +2[20(10-0)+(15-0)] [1]
bytes. Find out the base address and address of
element T[20][5], if an element T[2][2] is stored at = 42000+2[20(10+15)]
the memory location 3000. Find the total number = 42000+2[200+15]
of elements stored in T and number of bytes = 42000+2[215]
allocated to T. = 42000+430]
[CBSE SQP 2015] = 42430 [1]
Ans. Take T[2][2] as the base address [BA],
Q. 5 An array S[10][15] is stored in the memory with
sr = starting row, sc = starting column; each elements requiring 2 bytes of storage. If the
Along the row base address of array S is 25000, determine the
A[i][j] = BA + size[nc*(i - sr) + (j - sc)] location of S[5] [10] if the array is S stored along
T[20] [5] = 3000 + 4 [ 18 * (20 - 2) + (5 - 2)]
the column.
= 3000 + 4[(18 * 18) + (3)]
[CBSE Comptt., 2013]
= 3000 + 4[324 + 3] [1]
Ans. S[10][15] //Base address; 25000
= 3000 + 4(327)
W=2 bytes
= 3000 + 1308
= 4308 S[5][10] =?
nc = no. of columns sr =2 sc=2 m(row)=0 i =5
Total number of elements stored in T = 37*18 = n(column)=15 j =10 [1]
666 Array is stored in the memory along the column:
Total number of bytes allocated to T = 666 * 4 = P[i][j] = Base address + u[i+mxj]
2664 [2] s[5][10] = 25000+2[5+10x10]
Q. 4 An array A[20] [30] is stored along the row in the = 25000+2[5+100]
memory with each element requiring 4 bytes of = 25000+2[105]
storage. If the base address of array A is 32000, = 25000+210
find out the location of A[15][10]. Also, find the = 25210
total number of elements present in this array.
[0.D, 2014] Q. 6 An array T[15][10] is stored along the row in the
Ans. Array A[20][30] memory with each element requiring 8 bytes of
Base Address = 32000 storage. If the base address of array T is 14000,
Size of element(W)=4 bytes find out the location of T[101[7]. [0.D, 2013]
A[I][J]=A[15][10] hence I=15 and J=10 Ans. Base Address = 14000 = B
Total Row (R) = 20 T [I][J] = B + W [C[I-Ir] + (J-Jc)]
Total Column (C) = 30
= 14000 + 8 [10(10-0)+(7-0)]
A [I][J]=B + W[C(I-0)+(J-0)] [1]
= 14000 + 8 x 107
A[15][10]=32000 +4[30(15-0) + (10-0)] [1]
= 32000+4[30(15)+10] = 14000 + 856
= 32000+4[450+10] = 14856 [ 3]
= 32000+4[460] Q. 7 Each element of the array A[8][6] is stored using
= 32000+1840 4 bytes of memory. If the element A[2][4] is
= 33840 [1] An array T[25][20] is stored stored at location 936, find the address of A[5][1].
along the row in the memory with each Assume that the array is stored in Row Major.
[CBSE SQP 2013]
EduSuccess Smart Learning Centers I www.edusuccess.in I Contact # +91- 85 0606 1616 / 5252
ARRAYS LEARNING CENTERS FOR CLASSES VI -XII
int M)
{
for (int I = 0; I<N; I++)
for (int J=0; J<M/2; J++)
for (int I = N - 1; I>=0; I- -)
{
{
cout«endl; P [I] [M - J - 1] = T;
} }
OR
void REVCOL (int P [] [5], int N, int M) for (I = 0; I<N; I++)
{
{
}
stored in the memory along the row with each of
(1 Mark for correct nesting of loop(s) its element occupying 4 bytes, find the address
(1 1 /2 Mark for correct logic for reversing the of the element S[5][15], if the element S[8][10] is
content of each column) stored at the memory location 62,000.
Note :
• N and M can be written interchangeably for [CBSE Comptt., 2016]
number of rows and columns Q. 10. Write a
function REVROW (int N, int M) in C+ + to
EduSuccess Smart Learning Centers I www.edusuccess.in I Contact # +91- 85 0606 1616 / 5252
LEARNING CENTERS FOR CLASSES VI -XII
EduSuccess : Delhi's #1 Tuition Center for Computer Science, Class - 12
Q. 1 T[20][50] is a two dimensional array, which is For example, If the content of array is as
stored in the memory along the row with each of follows:
its element occupying 4 bytes, find the address 115 112 116 101 125
of the element T[15][5], if the element T[10][8] is 103 101 121 102 101
stored at the memory location 52000. 185 109 109 160 172
[Delhi, 2016]
The function should display the following as
Ans. T [20] [50] output :
Along the row 103 101 121 102 101
116 121 109
A [i] [j] = BA + size [((i - sr)*nc + j- sc)]
Ans. void SHOWMID (int P [] [5] , int R, int C)
T [10] [8] = 52000 {
EduSuccess Smart Learning Centers I www.edusuccess.in I Contact # +91- 85 0606 1616 / 5252
ARRAYS LEARNING CENTERS FOR CLASSES VI -XII
EduSuccess Smart Learning Centers I www.edusuccess.in I Contact # +91- 85 0606 1616 / 5252