Java 62.1
Java 62.1
PROBLEM STATEMENT:-
Write a program to obtain a matrix and find the sum of each row and each column.
Input format :
The first line of the input consists of the number of rows M and columns N separated by
space.
The next M lines of input consist of N elements in each line separated by space.
Output format :
The output prints the sum of each row and each column, separated by a line.
Refer to the sample outputs for the formatting specifications.
Code constraints :
1 <= M, N <= 10
-1000 <= elements <= 1000
AIM:-
ALGORITHM:-
PROGRAM:-
OUTPUT:-
RESULT:-
PROBLEM STATEMENT:-
In an array, Ravi is trying to determine how many odd and even elements there are. Aid him
in locating the same.
Write a program that counts the array's odd and even elements.
Input format :
The first line of the input consists of the value of n.
The second line consists of an array of elements separated by a space.
Output format :
The first line of the output consists of the number of even elements.
The second line of the output consists of the number of odd elements.
Refer to the sample output for the formatting specifications.
Code constraints :
1 <= n <= 10
-1000 <= elements <= 1000
AIM:-
ALGORITHM:-
PROGRAM:-
OUTPUT:-
RESULT:-
PROBLEM STATEMENT:-
Rithu is studying matrices in her computer science class, and she is intrigued by the concept
of lower triangular matrices. She wants to write a program that takes a square matrix as input
and transforms it into its corresponding lower triangular matrix.
Write a Java program that prompts the user for a square matrix, processes it to create the
lower triangular matrix, and then displays the result.
Input format :
The first line of input consists of two space-separated integers, m and n, representing the
number of rows and columns in the square matrix.
The next m lines of input consist of n space-separated integers each, representing the
elements of the square matrix.
Output format :
The first line of output displays the original matrix, then print the following format:
If the input matrix is not a square matrix (m ≠ n), print "Matrix entered should be a Square
Matrix" and return.
Otherwise, transform the given matrix into its lower triangular form and print the resulting
lower triangular matrix.
Refer to the sample output for the formatting specifications.
Code constraints :
1 <= m, n <= 10
1 <= elements <= 1000
Square matrix only
AIM:-
ALGORITHM:-
PROGRAM:-
OUTPUT:-
RESULT:-
PROBLEM STATEMENT:-
Write a program that finds the second-largest element in the array.
Input format :-
The first line of the input consists of the value of n.
The second line of input consists of an array of elements.
Output format:-
The output prints the second-largest element in the array.
Refer to the sample output for format specifications.
Code constraints :
1 <= n <= 20
1 <= arr[i] <= 1000
AIM:-
ALGORITHM:-
PROGRAM:-
OUTPUT:-
RESULT:-