Beruflich Dokumente
Kultur Dokumente
Lab 4
28 December 2018
Arrays
1. Write a C program to find sum of all array elements.
2. Write a C program to find maximum and minimum element in an array.
3. Write a C program to count the number of odd and even elements in an array.
4. Write a C program to copy all elements from an array to another array.
5. Write a C program to insert an element in an array at a specified position.
6. Write a C program to delete an element in an array at a specified position.
7. Write a C program to delete all duplicates element in an array.
8. Write a C program to merge two arrays to a third array.
9. Write a C program to reverse an array.
10. Write a C program to divide a given array into two arrays.
11. Write a C program to replace every element of an array with its next element
(the last element can be repalced by 1).
12. Given an array of N integers. The task is to find the smallest index of an
element such that when multiplied by -1 the sum of whole array becomes 0. If
there is no such index return -1.
13. Given an array of N elements, the task is to convert it into a permutation (each
number from 1 to N occurs exactly once) by using the following operations a
minimum number of times:
a) increment any number
b) decrement any number
14. Given an array of integers, a move constitutes choosing any element and
incrementing it by 1. Write a program that computes the number of moves
needed to make every value in an array unique.
15. Given a binary array (consisting of only 1s and 0s) write a program to find the
minimum number of operations needed to make the given array beautiful.
An array is considered beautiful if it has no consecutive 0s and 1s. The following
constitutes one operation:
a) cut the array into two parts
b) reverse one of these parts
c) join them again to create a whole array again.
If an array cannot be made beautiful return 1.