0% found this document useful (0 votes)
5 views4 pages

Array Based Problem

The document contains a series of programming tasks in C related to array manipulation. It includes instructions for storing, displaying, reversing, summing, copying, counting duplicates, tracking frequency, separating odd and even integers, deleting elements, and finding the second largest element in an array. Each task is accompanied by input examples and expected output results.

Uploaded by

kushagra dwivedi
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)
5 views4 pages

Array Based Problem

The document contains a series of programming tasks in C related to array manipulation. It includes instructions for storing, displaying, reversing, summing, copying, counting duplicates, tracking frequency, separating odd and even integers, deleting elements, and finding the second largest element in an array. Each task is accompanied by input examples and expected output results.

Uploaded by

kushagra dwivedi
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

Array Based Problem:

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


Input :
Input 10 elements in the array :
element - 0 : 1
element - 1 : 1
element - 2 : 2

Output :
Elements in array are: 1 1 2 3 4 5 6 7 8 9s
2) Write a program in C to read n number of values in an array and display them
in reverse order.

Input :
Input the number of elements to store in the array :3
Input 3 number of elements in the array :
element - 0 : 7
element - 1 : 8
element - 2 : 9

Output :
The values store into the array are :
789
The values store into the array in reverse are :
987

3) 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) 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 :
element - 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) 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) 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

7) 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

8) Write a program in C to delete an element at a desired position from an array.

Test Data :
Input the size of array : 5
Input 5 elements in the array in ascending order:
element - 0 : 1
element - 1 : 2
element - 2 : 3
element - 3 : 4
element - 4 : 5
Input the position where to delete: 3

Expected Output :
The new list is : 1 2 4 5
9) 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