Question: Problem Description:Write a program that prints the second largest element of a given array First line of the program will take an integer input N.

Problem Description:Write a program that prints the second largest element of a given array

First line of the program will take an integer input N.

Next line will have N space separated integers.

Constraints:

First line: 5 <= N <= 100000

Next N integers: -100000 <= ni<= 100000

Skeleton Code:

// you name here import java.util.*;

public class cmsc401 { private static final Scanner scanner = new Scanner(System.in);

// Please use these methods to take inputs and write outputs. private static Integer readInt() { return scanner.nextInt(); }

private static String readString() { return scanner.next(); }

private static Integer[] readIntegerArray(int size) { Integer[] array = new Integer[size]; for (int i = 0; i < size; i++) { array[i] = readInt(); } return array; }

private static void printInt(int a) { System.out.println(a); }

private static void printString(String s) { System.out.println(s); }

public static void main(String[] args) {

// // reading an Integer // Integer a = readInt(); // // writing int output // printInt(a); // // // reading a String // String s = readString(); // // writing string output // printString(s); // // // reading an Integer Array (you should provide the size) // Integer[] listOfIntegers = readIntegerArray(5);

// write your code here } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!