IEO Level 2- English Olympiad (SOF) Class 9 Coaching Programs

⏳ 🎯 Online Tests (2 Tests [50 Questions Each]): NTA Pattern, Analytics & Explanations

Click Here to View & Get Complete Material

Rs. 200.00

3 Year Validity (Multiple Devices)

🎓 Study Material (303 Notes): 2024-2025 Syllabus

Click Here to View & Get Complete Material

Rs. 450.00

3 Year Validity (Multiple Devices)

🎯 250 MCQs (& PYQs) with Full Explanations (2024-2025 Exam)

Click Here to View & Get Complete Material

Rs. 200.00

3 Year Validity (Multiple Devices)

Array Computer Solutions: Two-Dimensional Array: Initialization of Two-Dimensional Array

Two-Dimensional Array

It has two subscript or index, first for row and second for column. For example:

int

The above has five rows and four columns. The total numbers of elements are 20. The subscripts of 20 elements are:

Initialization of Two-Dimensional Array

The initialization is done at the time of declaration of an array.

For example:

int A [2] [4] = {1, 2, 3, 4, 5,6, 7,8) .

For more clarity

int A [2] [4] = { {1,2, 3,4} , {5,6, 7,8} } .

The above data can be grouped. The inner braces are ignored by the compiler.

For two-dimensional array, two loops are required. The following program finds out the maximum value stored in two-dimensional array.

# include, iostream. h >

const int M = 5.

void main ()

{

int A [M] [M] , i, j, T.

cout ≫ “⧵n Enter Array Elements” .

for (i = 0; i < = M - 1; i ++)

for (j = 0; j < = M - 1; j ++)

cin ≫ A [i] [j] .

T = A [0] [0] .

for (i = 0; i < = M - 1; i ++)

for (j = 0; j < = M - 1; j ++)

{

If (T < A [i] [j]

T = A [i] [j] .

}

cout ≪ “Largest value” ≪ T ≪ “⧵n”

}