My Blog
Articles related to programming, computer science, technology and research.

Java program to reverse the array inplace

18/10/2016 Categories: Arrays. 2 Comments on Java program to reverse the array inplace

Following program reads an array of elements and reverses the array in place i.e., without using any temporary array: import java.util.Scanner; public class Driver { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println(“Enter the no. of elements: “); int n = input.nextInt(); int a[] = new int[n]; System.out.println(“Enter ” + n […]

Read the rest of this entry »

Java program to find the maximum and minimum element in an array

18/10/2016 Categories: Arrays. No Comments on Java program to find the maximum and minimum element in an array

Following program reads array elements from the user and finds out the maximum, minimum elements in the array:

  Input and output for the above program are as follows:

 

Read the rest of this entry »

Java program for matrix multiplication and matrix transpose

07/06/2016 Categories: Arrays. Comments Off on Java program for matrix multiplication and matrix transpose

Java program to check the compatibility for multiplication, if compatible multiplies two matrices and find its transpose.

Input and output for the above program is as follows: Enter no of rows in first matrix: 3 Enter no of columns in first matrix: 3 Enter no of rows in second matrix: 3 Enter no of columns […]

Read the rest of this entry »

Sorting an array in Java

02/05/2016 Categories: Arrays. Comments Off on Sorting an array in Java

In this program we will see how to sort an array in Java. I have used exchange sort to sort the array in asceding order. The program is as follows:

Input and Output of the above program is given below:

If you need further explanation for this program, please comment below.

Read the rest of this entry »

Basic array programs in Java

02/05/2016 Categories: Arrays. Comments Off on Basic array programs in Java

In this post we are going to look at some very basic and frequently asked array programs in Java. Different programs are written as separate functions in the class¬†ArrayClass. These programs are restricted to integers. Following programs are available: Reading elements into an array Printing elements in an array Printing the sum of all elements […]

Read the rest of this entry »
Scroll Up