info@meritcampus.com    +91-85006-22255
...
`

### Intermediate Level Test 6 has these questions

Find maximum number in array

Write a program to find the maximum number in array.
Input (Integer Array) Output (Integer)
{2, 3, 4, 7, 6, 1} 7
{3, 9, 1, 5, 16, 10} 16
{195, 31876, 123, 20000, 15122, 789} 31876
{36187, 31876, 38761, 37861, 37618, 38671} 38761
``` class MaximumNumberInArray {    public static void main(String s[])    {        int[] input = {2, 3, 8, 5, 4};        int maximum = getMaximumNumberInArray(input);        System.out.println("Maximum Number is " + maximum);    } public static int getMaximumNumberInArray(int[] array) { int result = 0; //Write code here to get maximum number in array and assign it to result return result; } } ```

Print triangle formation

Write a program to print the following formation depending upon the size. Use System.out.println or System.out.print for printing.
Input (Integer) Output
5 `_ _ _ _ \      / \    /  \  /   \/`
6 `_ _ _ _ _ \        / \      /  \    /   \  /    \/`
8 `_ _ _ _ _ _ _\            / \          /  \        /   \      /    \    /     \  /      \/`
``` class PrintInvertedTriangleShape {    public static void main(String s[])    {        printFormation(5);    } public static void printFormation(int columnsSize) { //Write code here to print the required formation depending upon the columnsSize. Use System.out.println or System.out.print for printing. } } ```

Reverse the input array

Write a program to reverse the input array.
Input (Integer Array) Output (Integer Array)
`{2, 3, 4, 7, 6, 1}` `{1, 6, 7, 4, 3, 2}`
`{3, 9, 1, 5, 16, 10}` `{10, 16, 5, 1, 9, 3}`
``` class ReverseOfArray {    public static void main(String s[])    {        int[] input = {2, 6, 3, 8, 1};        int[] output = reverseOfArray(input);        System.out.print("Reverse of the array is : " );        for(int outputElement : output)        {            System.out.print(outputElement + ", ");        }    } public static int[] reverseOfArray(int[] input) { int[] output = null; //Write code here to reverse input array and assign it to output return output; } } ```

Sum all elements in array

Write a program to get the sum of all elements in array.
Input (Integer Array) Output (Integer)
{2, 3, 4, 7, 6, 1} 2 + 3 + 4 + 7 + 6 + 1 = 23
{3, 9, 1, 5, 16, 10} 3 + 9 + 1 + 5 + 16 + 10 = 44
{21, 22, 23, 80, 443, 1521, 8000, 8080} 21 + 22 + 23 + 80 + 443 + 1521 + 8000 + 8090 = 18190
``` class SumOfNumbersInArray {    public static void main(String s[])    {        int sum = getSumOfArrayElements(new int[]{2, 3, 4, 5, 8});        System.out.println("Sum of elements in array is " + sum);    } public static int getSumOfArrayElements(int[] array) { int result = 0; //Write code here to get sum of array elements and assign it to result return result; } } ```

Multiply every array double element with 60

Write a program to multiply every array element with 6.0.
Input (Double Array) Output (Double Array)
{2.0, 3.1, 4.3, 7.5, 6.2, 1.0} {12.0, 18.6, 25.8, 45.0, 37.2, 6.0}
{3.0, 9.0, 1.0, -5.0, -16.0, 10.0} {18.0, 54.0, 6.0, -30.0, -96.0, 60.0}
``` class MultiplyEveryArrayElement {    public static void main(String s[])    {        double[] input = {2.0, 3.1, 4.3, 7.5, 6.2, 1.0};        double[] output = multiplyEveryElement(input);        System.out.print("Result after multiplying by 6.0 is : ");        for(double outputElement : output)        {            System.out.print(outputElement + ", ");        }    } public static double[] multiplyEveryElement(double[] input) { double[] result = null; //Write code here to multiplyEveryElement with 6.0 and assign it to result. return result; } } ```