0% found this document useful (0 votes)
2 views

Untitled document

The document contains a series of programming tasks in Java, including operations on arrays such as calculating sums, finding elements, averaging marks, adding matrices, reversing arrays, and identifying maximum and minimum elements. Each task includes input examples and expected output. The tasks demonstrate basic array manipulation and algorithm implementation in Java.

Uploaded by

Sahil Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Untitled document

The document contains a series of programming tasks in Java, including operations on arrays such as calculating sums, finding elements, averaging marks, adding matrices, reversing arrays, and identifying maximum and minimum elements. Each task includes input examples and expected output. The tasks demonstrate basic array manipulation and algorithm implementation in Java.

Uploaded by

Sahil Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

1. Create an array of 5 floats and calculate their sum.

Input:
numbers = {1.2f, 2.5f, 3.1f, 4.0f, 5.7f};

Expected Output:
Sum = 16.5

2. Write a program to find out whether a given integer is


present in an array or not.
Input:
arr = {10, 20, 30, 40, 50};
int target = 30;

Expected Output:
30 is present in the array.

3. Calculate the average marks from an array


containing marks of all students in Physics using for-
each loop.
Input:
marks = {85, 90, 78, 88, 76};

Expected Output:
Average marks = 83.4

4. Create a Java program to add two matrices of size 2


× 3.
Input:
matrix1 = {{1, 2, 3}, {4, 5, 6}};
matrix2 = {{7, 8, 9}, {10, 11, 12}};

Expected Output:
8 10 12
14 16 18

5. Write a Java program to reverse an array.


Input:
arr = {1, 2, 3, 4, 5};

Expected Output:
Reversed array: 5 4 3 2 1

6. Write a Java program to find the maximum element


in an array.
Input:
arr = {45, 78, 12, 34, 90, 67};

Expected Output:
Maximum element: 90

7. Write a Java program to find the minimum element in


a Java array.
Input:
int[] arr = {45, 78, 12, 34, 90, 67};

Expected Output:
Minimum element: 12
8. Write a Java program to find whether an array is
sorted or not.
Input:
arr = {1, 2, 3, 4, 5};

Expected Output:
Array is sorted.

You might also like