Posts

Showing posts from June, 2021

USER INPUT PRINT ORIGINAL,REVERSE ARRAY AND SORTED ARRAY

  package com.cnc ; import java.io.OutputStream ; import java.util.Scanner ; public class Main { public static void main ( String [] args) { Scanner sc = new Scanner( System . in ); System . out .println( "How many values do you want?" ); int count = sc .nextInt(); int [] array = new int [ count ]; for ( int i = 0 ; i < count ; i++) { System . out .println( "Enter array element " + (i + 1 )); array [i] = sc .nextInt(); } System . out .println( "Original element " ); for ( int i = 0 ; i < count ; i++) { System . out .print( array [i] + " " ); } System . out .println( "" ); System . out .println( "Reversed element " ); for ( int i = count - 1 ; i >= 0 ; i--) { System . out .print( array [i] + " " ); } //////////////// SORTED ARRAY /////////////////