0% found this document useful (0 votes)
21 views

Assignment3 DDA

Uploaded by

valorantopop69
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Assignment3 DDA

Uploaded by

valorantopop69
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Grade 10

Assignment 3
Double Dimensional Array Questions

Q1 Initialize the following data elements in to an array Arr[ ][ ] of size 2X3.


3 2 5
2 9 6
Q2 Which of the following is correct way to initialize a 3X2 two-dimensional array?
(a) int dim[ ][ ] = {{1,2,3},{8,7,6}};
(b) int dim[ ][ ] = new int{{1,2,3},{8,7,6}};
(c) int dim[ ][ ] = {{1,2,3,8,7,6}};
(d) int dim[ ][ ] = {{1,2},{5,4},{8,7}};

Q3. Consider the following two-dimensional array and answer the questions given below:
int x[][] ={{4,3,2}, {7,8,2}, {8, 3,10}, {1, 2, 9}};
(a) What is the order of the array?
(b) What is the value of x[0][0]+x[2][2]?

Q4 Which of the following represents the second element of the second row in a multi-
dimensional
array?
a) arr[0][1]
b) arr[0][0]
c) arr[1][0]
d) arr[1][1]

Q5 Write a program in Java to store the numbers of a 3 X 3 matrix in a double


dimensional array. Find the sum of the numbers of each row and the sum of each of the
numbers of each column of the matrix by using an input statement.
sample input:
The number of the Matrix are :
12 20 13
14 18 11
21 11 12
Sample Output :
The sum of the elements of each row:
The sum of the elements of 1st row = 45
The sum of the elements of 1st row = 43
The sum of the elements of 1st row = 44
The sum of the elements of each column:
The sum of the elements of 1st column = 47
The sum of the elements of 1st column = 49
The sum of the elements of 1st column = 36
Q6 Write a program to assign values to a double dimensional character array CHA[ ][ ] of
size 3x4. Print this array in matrix format as shown below and count and print how many
number of letters, digits and special characters are present in the array.
Sample output:
Ax3S
@WPr
L!09
No of letters= 7
No of digits= 3
No of special characters=2
Q7 Write a program to accept elements in a double dimensional array of size m x n
(accept m,n from user). Calculate and print sum of all elements and also print the DDA in
matrix format as shown below.
Sample output for 3X4 DDA
1234
4562
-3 8 0 1
Sum of all the elements = 33

Q8 An array is referred to as a ‘Special array’ if it has equal number of 0s and 1s in it.


Write a program to accept some positive integers in a DDA (double dimensional array) of
size 4x4 and check whether it is a special array or not. Display an error message if the
array does not contain any ‘zero’ and ‘one’.
Example:
n[ ][ ] = { { 1,3,1,0 }, { 2,4,5,6 }, { 2,0,8,0 }. { 1,7,5,9 } } ;
Total number of 0s = 3
Total number of 1s = 3
Hence, the array n[ ][ ] is a Special array.

Q9 Write a program in Java to store the number in 4x4 matrix in a double dimensional
array find the highest and the lowest number of the matrix by using an input statement.
Sample Input:
The numbers of matrix are
12 21 13 14
24 41 51 33
61 11 30 29
59 82 41 76
Sample Output:
The lowest number in array = 11
The lowest number in array = 82

Q10 Define a class to accept values into an integer array of order 4 x 4 and check whether
it is DIAGONAL array or not. An array is DIAGONAL if the sum of the left diagonal
elements equals the sum of the right diagonal elements. Print the appropriate message
Example: 3 4 2 5
2 5 2 3
5 3 2 7
1 3 7 1
Sum of the left diagonal elements
3 + 5 + 2 + 1 = 11
Sum of the right diagonal elements
5 + 2 + 3 + 1 = 11

You might also like