Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

Data Structures and Algorithms Lab FALL, 2022 Fast

NUCES, Islamabad

Q#1: Write a c++ program to check if two 2d arrays of size 3X3 are equal. Values
will be entered by the user in the array.

Q#2: Write a c++ program to print the sum of elements of a 2d array of size 3X3.
Values will be entered by the user in the array.

For example:

1 2 3

4 5 6

7 8 9

Sum is : 45

Q#3: Write a c++ program to print the sum of individual row in a 2d array of size
3X3. Values will be entered by the user in the array.

For example:

1 2 3

4 5 6

7 8 9

Sum of first row is : 6

Sum of second row is : 15

Sum of third row is : 24

Q#4: Write a c++ program to print the sum of individual column in a 2d array of
size 3X3. Values will be entered by the user in the array.

For example:

1 2 3

4 5 6

7 8 9

Sum of first column is : 12

Sum of second column is : 15

Sum of third column is : 18

Q#5: Write a c++ program to add two 2d arrays of size 3X3. Values will be entered
by the user in the array.

For example:
First array: Second array:

1 2 3 3 2 1

4 5 6 1 4 -3

7 8 9 -6 8 7

Sum is :

4 4 4

5 9 3

1 16 16

Q#6: Write a c++ program to check if a 2d array of size 3X3 is a identity matrix.
Values will be entered by the user in the array.

Identity matrix :

1 0 0

0 1 0

0 0 1

Q#7: Write a c++ program to print transpose of a 2d array of size 3X3. Values will
be entered by the user in the array.

For example:

1 2 3

4 5 6

7 8 9

Its transpose will be

1 4 7

2 5 8

3 6 9

Q#8: Write a c++ program to print the sum of right diagonal of 2d array of size
3X3. Values will be entered by the user in the array.

For example:

1 2 3

6 1 -9

2 4 1

Sum of right diagonal is : 3


Q#9: Write a c++ program to check if two 2d arrays can be multiplied.

Q#10: Write a c++ program to find the pair having sum 12 from the given elements
(Uni-dimmensional array). Values will be entered by the user in the array.

For example:

4 3 11 7 -9 1 2 8

Output should be :

Pair having sum 12 is : 4 and 8


11 and 1

Q#11: Write a c++ program to check if the digits in a three digit number entered by
the user are consecutive,
irrespective of their order (Uni-dimmensional array). Values will be entered by the
user in the array.

For example:

If the user entered 132 or 123 or 213 or 231 or 321 or 312, the console should
prompt "They are consecutive numbers".

If the user entered 135, the console should prompt "They are not consecutive
numbers".

You might also like