Question
Write a Java program to input 10 integers in a 1D array, count and display the number of even numbers
and odd numbers present in the array.
Code:
Output:
Variable Description Table
Variable Data Type Description
arr int[] Array to store 10 integers
Variable Data Type Description
i int Loop counter
evenCount int Stores the count of even numbers
oddCount int Stores the count of odd numbers
sc Scanner For taking user input
Question
Write a Java program to input a 3×3 matrix and check whether it is a symmetric matrix or not.
[Hint: A symmetric matrix is a matrix which after transpose (rows become columns or vice versa) remain
same]
Code:
Output:
Variable Description Table
Variable Data Type Description
mat int[][] 2D array (matrix) of size 3×3
i, j int Loop counters for rows and columns
isSymmetric boolean Stores whether the matrix is symmetric
sc Scanner For taking user input