5.2.2. Defining a 2D array, Chapter - 5, Arrays and String, HSSC-II (12th Class) Computer Science Key Point Notes

5.2.2. Defining a 2D array, Chapter - 5, Arrays and String, HSSC-II (12th Class) Computer Science Key Point Notes

12th Class (HSSC-II) Computer SLO Based Key Point Notes

(National Book Foundation - As Federal Textbook Board, Islamabad 
Based on National Curriculum Pakistan 2023-2024 and Onward prescribed by Federal Board of Intermediate and Secondary Education, Islamabad, and All Pakistan Boards) 

{Contact WhatsApp 03339719149 for Class-XII Computer Science Complete SLO-Based Key Points notes in pdf format as well as in PowerPoint Presentation for preparing/delivering the Lectures}

************************************

👉👉👉 Computer Science 12th Class Notes (Main Page)

************************************

Unit 5: Arrays and String


5.2.2. Defining and Initializing a Two-Dimensional Array:

Defining a 2D array

To define a 2D Araay in C++, the type of the elements, the name of the array, and the number of elements it is required to store in rows and columns is mentioned in the declaration statement.  Following is the general syntax of the declaration of the 2D array in C++:
           
         data_type Array_name[Row size][column size];

For example:         int table [5][2];



To specify any element in a 2D array, we need the array name followed by row no. and column no.

Initializing 2D Array

A 2D array can be initialized by assigning values row-wise as given below:

            int table[3][2] = { { 2, 3 }, { 34, 1 }, { 3, 31} };

Nested braces are used for assigning values row-wise.

************************************
👉👉👉 Computer Science 12th Class Notes (Main Page)

************************************


************************************
Shortcut Links For:

1.  5th Class All Subjects Notes

2.  8th Class All Subjects Notes

3.  Easy English Grammar Notes



1. Website for School and College Level Physics   
2. Website for School and College Level Mathematics  
3. Website for Single National Curriculum Pakistan - All Subjects Notes 

© 2023 & onwards Academic Skills and Knowledge (ASK  

Note:  Write me in the comments box below for any query and also Share this information with your class-fellows and friends.

Post a Comment

0 Comments

cwebp -q 80 image.png -o image.webp