0% found this document useful (0 votes)
6 views3 pages

Array Operations: Sum, Max, Min, Sort

The document outlines ten programming problems related to array manipulation, including tasks such as calculating the sum, finding maximum and minimum elements, counting even and odd numbers, reversing the array, searching for an element, copying elements, finding frequency, sorting, and identifying the second largest element. Each problem includes a problem statement, input format, output format, and sample input/output. These exercises are designed to enhance programming skills in array handling.

Uploaded by

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

Array Operations: Sum, Max, Min, Sort

The document outlines ten programming problems related to array manipulation, including tasks such as calculating the sum, finding maximum and minimum elements, counting even and odd numbers, reversing the array, searching for an element, copying elements, finding frequency, sorting, and identifying the second largest element. Each problem includes a problem statement, input format, output format, and sample input/output. These exercises are designed to enhance programming skills in array handling.

Uploaded by

ishitamittal1512
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1 Sum of Array Elements

Problem Statement Write a program to find the sum of all elements in an array.
Input Format First line: An integer N (size of array)
Second line: N space-separated integers.
Output Format Print the sum of all elements.
Sample Input 5
2 4 6 8 10
Sample Output 30

2 Maximum Element in Array


Problem Statement Write a program to find the maximum element in an array.
Input Format First line: An integer N
Second line: N space-separated integers.
Output Format Print the maximum element.
Sample Input 6
382951
Sample Output 9

3 Minimum Element in Array


Problem Statement Write a program to find the minimum element in an array.
Input Format First line: Integer N
Second line: N space-separated integers.
Output Format Print the minimum element.
Sample Input 4
7352
Sample Output 2

4 Count Even and Odd Numbers


Problem Statement Write a program to count the number of even and odd elements in an array.
Input Format First line: Integer N
Second line: N space-separated integers.
Output Format Print two integers – count of even and count of odd numbers.
Sample Input 5
12345
Sample Output 23

5 Reverse the Array


Problem Statement Write a program to print the elements of an array in reverse order.
Input Format First line: Integer N
Second line: N space-separated integers.
Output Format Print the array elements in reverse order.
Sample Input 5
10 20 30 40 50
Sample Output 50 40 30 20 10

6 Search an Element in Array


Problem Statement Write a program to search for an element in an array.
Input Format First line: Integer N
Second line: N space-separated integers
Third line: Integer X (element to search).
Output Format Print “Found” if X is present, otherwise “Not Found”.
Sample Input 6
2 4 6 8 10 12
8
Sample Output Found

7 Copy Elements to Another Array


Problem Statement Write a program to copy all elements from one array to another.
Input Format First line: Integer N
Second line: N space-separated integers.
Output Format Print elements of the new copied array.
Sample Input 4
5 10 15 20
Sample Output 5 10 15 20

8 Find Frequency of Each Element


Problem Statement Write a program to find the frequency of each element in the array.
Input Format First line: Integer N
Second line: N space-separated integers.
Output Format Print each element with its frequency.
Sample Input 6
122314
Sample Output 1→2
2→2
3→1
4→1

9 Sort the Array in Ascending Order


Problem Statement Write a program to sort the elements of an array in ascending order.
Input Format First line: Integer N
Second line: N space-separated integers.
Output Format Print sorted array elements.
Sample Input 5
42861
Sample Output 12468
10 Find Second Largest Element
Problem Statement Write a program to find the second largest element in an array.
Input Format First line: Integer N
Second line: N space-separated integers.
Output Format Print the second largest element.
Sample Input 6
12 35 1 10 34 1
Sample Output 34

You might also like