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

Array

The document provides a series of C++ programming exercises focused on array manipulation, including storing and printing elements, reversing arrays, calculating sums, copying arrays, counting duplicates, printing unique elements, counting frequencies, finding maximum and minimum values, separating odd and even integers, and identifying the second largest element. Each exercise includes test data and expected output to guide implementation. The exercises aim to enhance understanding of array operations in C++.

Uploaded by

ym895190
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)
6 views

Array

The document provides a series of C++ programming exercises focused on array manipulation, including storing and printing elements, reversing arrays, calculating sums, copying arrays, counting duplicates, printing unique elements, counting frequencies, finding maximum and minimum values, separating odd and even integers, and identifying the second largest element. Each exercise includes test data and expected output to guide implementation. The exercises aim to enhance understanding of array operations in C++.

Uploaded by

ym895190
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/ 4

1.

Array Store & Print


Write a program in C++ to store elements in an array and print them.

Computer programming software


Test Data :
Input 10 elements in the array :
element - 0 : 1
element - 1 : 1
element - 2 : 2
.......
Expected Output :
Elements in array are: 1 1 2 3 4 5 6 7 8 9

2. Array Reverse Display


Write a program in C++ to read n number of values in an array and display
them in reverse order.
Test Data :
Input the number of elements to store in the array :3
Input 3 number of elements in the array :
element - 0 : 2
element - 1 : 5
element - 2 : 7
Expected Output :
The values store into the array are :

Computer programming software


257
The values store into the array in reverse are :
752

3. Array Sum Calculation


Write a program in C++ to find the sum of all elements of the array.
Test Data :
Input the number of elements to be stored in the array :3
Input 3 elements in the array :
element - 0 : 2
element - 1 : 5
element - 2 : 8
Expected Output :
Sum of all elements stored in the array is : 15
4. Array Copy
Computer programming software

Write a program in C++ to Copy the elements of one array into another
array.
Test Data :
Input the number of elements to be stored in the array :3
Input 3 elements in the array :
elem[ent - 0 : 15
element - 1 : 10
element - 2 : 12
Expected Output :
The elements stored in the first array are :
15 10 12
The elements copied into the second array are :
15 10 12

5. Count Duplicate Elements


Write a program in C++ to count the total number of duplicate elements in
an array.
Test Data :
Input the number of elements to be stored in the array :3
Input 3 elements in the array :
element - 0 : 5
element - 1 : 1
element - 2 : 1
Expected Output :
Total number of duplicate elements found in the array is : 1

6. Print Unique Elements


Write a program in C++ to print all unique elements in an array.
Test Data :
Print all unique elements of an array:
------------------------------------------
Input the number of elements to be stored in the array: 4
Input 4 elements in the array :
element - 0 : 3
element - 1 : 2
element - 2 : 2
element - 3 : 5
Expected Output :
The unique elements found in the array are:
35

7. Frequency of Array Elements


Write a program in C++ to count the frequency of each element of an array.
Test Data :
Input the number of elements to be stored in the array :3
Input 3 elements in the array :
element - 0 : 25
element - 1 : 12
element - 2 : 43
Expected Output :
The frequency of all elements of an array :
25 occurs 1 times
12 occurs 1 times
43 occurs 1 times

8. Find Maximum & Minimum


Write a program in C++ to find the maximum and minimum elements in an
array.
Test Data :
Input the number of elements to be stored in the array :3
Input 3 elements in the array :
element - 0 : 45
element - 1 : 25
element - 2 : 21
Expected Output :
Maximum element is : 45
Minimum element is : 21

9. Separate Odd & Even Arrays


Write a program in C++ to separate odd and even integers into separate
arrays.
Test Data :
Input the number of elements to be stored in the array :5
Input 5 elements in the array :
element - 0 : 25
element - 1 : 47
element - 2 : 42
element - 3 : 56
element - 4 : 32
Expected Output :
The Even elements are :
42 56 32
The Odd elements are :
25 47
10. Second Largest Element

Write a program in C++ to find the second largest element in an array.


Test Data :
Input the size of array : 5
Input 5 elements in the array :
element - 0 : 2
element - 1 : 9
element - 2 : 1
element - 3 : 4
element - 4 : 6
Expected Output :
The Second largest element in the array is : 6

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy