Skip to content

Latest commit

 

History

History

List Of Programs and Output for Experiment 2

array_sum.java - Program to find the sum of elements in an array

Enter the number of elements:
5
Enter the elements:
1
2
3
4
5
Sum of 5 elements is 15

smallest_in_array.java - Program to find the smallest element in an array

Enter the number of elements:
5
Enter the elements of the array :
3
4
2
1
5
smallest element is 1

replace_array_element.java - Program to replace a particular element in an array.

Enter the required size:
5
Enter the elements: 
1
2
3
4
5
Enter which new element you want to insert: 
4
Enter the position to add number :
1
Final output=
        4
        2
        3
        4
        5

second_largest_array.java - Program to find the second largest element in an array.

Enter the size:
5
Enter the elements: 
3
4
2
1
5
Second largest no=4

largest_in_matrix.java - Program to find the largest element in an NXN matrix.

Enter the no of rows: 
3
Enter the no of columns: 
3
Enter the elements :
1
2
3
4
5
6
7
8
9
The largest element in the mnatrix = 9

add_marix.java - Program to add two matrices.

Enter the number of rows of the matrics
3
Enter the number of columns of the matrics
3
Enter the elements of the first matrix :
1
2
3
4
5
6
7
8
9
Enter the elements of the second matrix :
9
8
7
6
5
4
3
2
1
Resultant Matrix 
10      10      10
10      10      10
10      10      10

trans_matrix.java - Program to find transpose of a matrix.

Enter the number of rows of the matrix
3
Enter the number of columns of the matrix
3
Enter the elements of the first matrix :
1
2
3
4
5
6
7
8
9
Transpose of the matrix is 
1       4       7
2       5       8
3       6       9

multiply_matrix.java - Program to multiply two matrices.

Enter the number of rows of matrix(1)
3
Enter the number columns of matrix(1)
3
Enter the number of rows of matrix(2)
3
Enter the number of columns of matrix(2)
3
Enter the elements of matrix1
1
2
3
4
5
6
7
8
9
Enter the elements of matrix2
9
8
7
6
5
4
3
2
1


output matrix:-
30 24 18
84 69 54
138 114 90

trace_matrix.java - Program to find trace of matrix.

enter the order of square matrix:
3
enter the elements:
1
2
3
4
5
6
7
8
9
trace of matrix is 15

string_palindrome.java - Program to find whether a string is palindrome or not.

enter the string:
malayalam 
The String is palindrome

search_character.java - Program to search for a particular character in a string.

Enter string
amazed
Enter character to be searched
d
character found at position 6

replace_character.java - Program to replace a particular character in a string.

Enter length of the string
5
Enter  a string
akash
Enter the location of the character to be replaced
1
Enter the character which is to be replaced with
q
New string is
qkash

frequency_of_character.java - Program to find frequency of a given character in a string.

Enter string
malayalam
Enter the character to find the frequency
a
frequency of a is 4