P-1) Define a class to accept values into a 3×3 array and check if it is a special array.
An array
is a special array if the sum of the even elements = sum of the odd elements.
Example:
A[][]={{ 4 ,5, 6}, { 5 ,3, 2}, { 4, 2, 5}};
Sum of even elements = 4+6+2+4+2 =18
Sum of odd elements= 5+5+3+5=18
P-2) Write a program to input numbers into a 5×5 integer matrix and check whether it is a diagonal matrix
or not. Diagonal matrix is such a matrix whose major diagonal elements are non-zeroes and rest of
the elements are zeroes.
P-3) Write a program to take an integer array of 10 elements from user and key element to be searched
and using linear search technique, find the location of key element in the array.
Write a program to input numbers into a 5×5 integer matrix and find the sum of each row
separately.
For example, if the given matrix is:
1 2 3 5 2
7 6 8 9 2
1 7 11 3 4
3 2 5 9 8
5 5 3 2 1
Output:
Sum of row 1 = 13 Sum of row 4 = 27
Sum of row 2 = 32 Sum of row 5 = 16
Sum of row 3 = 26
P-4) Write a program to input numbers into a 5×5 integer matrix and find the sum of each column separately.
For example, if the given matrix is:
1 2 3 5 2
7 6 8 9 2
1 7 11 3 4
3 2 5 9 8
5 5 3 2 1
Output:
Sum of column 1 = 17 Sum of column 4 = 28
Sum of column 2 = 22 Sum of column 5 = 17
Sum of column 3 = 30
P-5) Write a program to input 10 numbers into an integer array and find the frequency of the largest
number. For example, if the array contains: a[0] a[1] a[2] a[3] a[4] a[5] a[6] a[7] a[8] a[9] 9 89 3 7 89
34 15 16 67 89 Output should be: Frequency of largest number = 3
P-6) Write a program to input 10 numbers into an integer array and store all even numbers into one array
and all odd numbers into another array. Display all the three arrays.
For example, if the given array contains:
a[0] a[1] a[2] a[3] a[4] a[5] a[6] a[7] a[8] a[9]
99 12 34 7 87 36 94 16 14 45
The resultant arrays should be:
b[0] b[1] b[2] b[3] b[4] b[5]
12 34 36 94 16 14
c[0] c[1] c[2] c[3]
99 7 87 45
P-1) Define a class to accept values into a 3×3 array and check if it is a special array. An array
is a special array if the sum of the even elements = sum of the odd elements.
Example:
A[][]={{ 4 ,5, 6}, { 5 ,3, 2}, { 4, 2, 5}};
Sum of even elements = 4+6+2+4+2 =18
Sum of odd elements= 5+5+3+5=18
P-2) Write a program to input numbers into a 5×5 integer matrix and check whether it is a diagonal matrix
or not. Diagonal matrix is such a matrix whose major diagonal elements are non-zeroes and rest of
the elements are zeroes.
P-3) Write a program to take an integer array of 10 elements from user and key element to be searched
and using linear search technique, find the location of key element in the array.
Write a program to input numbers into a 5×5 integer matrix and find the sum of each row
separately.
For example, if the given matrix is:
1 2 3 5 2
7 6 8 9 2
1 7 11 3 4
3 2 5 9 8
5 5 3 2 1
Output:
Sum of row 1 = 13 Sum of row 4 = 27
Sum of row 2 = 32 Sum of row 5 = 16
Sum of row 3 = 26
P-4) Write a program to input numbers into a 5×5 integer matrix and find the sum of each column separately.
For example, if the given matrix is:
1 2 3 5 2
7 6 8 9 2
1 7 11 3 4
3 2 5 9 8
5 5 3 2 1
Output:
Sum of column 1 = 17 Sum of column 4 = 28
Sum of column 2 = 22 Sum of column 5 = 17
Sum of column 3 = 30
P-5) Write a program to input 10 numbers into an integer array and find the frequency of the largest
number. For example, if the array contains: a[0] a[1] a[2] a[3] a[4] a[5] a[6] a[7] a[8] a[9] 9 89 3 7 89
34 15 16 67 89 Output should be: Frequency of largest number = 3
P-6) Write a program to input 10 numbers into an integer array and store all even numbers into one array
and all odd numbers into another array. Display all the three arrays.
For example, if the given array contains:
a[0] a[1] a[2] a[3] a[4] a[5] a[6] a[7] a[8] a[9]
99 12 34 7 87 36 94 16 14 45
The resultant arrays should be:
b[0] b[1] b[2] b[3] b[4] b[5]
12 34 36 94 16 14
c[0] c[1] c[2] c[3]
99 7 87 45