Assume that we have an array of elements (non-negative numbers). Now, write a program in C++ to find the index of the smallest number in the array so that removal of the element will make the sum of remaining numbers in the array will be divisible by the given number (N) specified by the user (means, user defined number). If No such element present in the array which removal will not make sum of the array element divisible by N, then print "-1". Note: Using of Any STL library functions will not be acceptable. For better understanding of the above program, please go through the following samplee examples Example input 01: Array elements: {24,8,17,4,12} N=8 Output: 2 Explanation if you remove 17 from the array and sum remaining elements 24+8+4+12 = 48 so, 48 is divisible by 8 so, index of 17 is 2 output is 2.
Assume that we have an array of elements (non-negative numbers). Now, write a program in C++ to find the index of the smallest number in the array so that removal of the element will make the sum of remaining numbers in the array will be divisible by the given number (N) specified by the user (means, user defined number). If No such element present in the array which removal will not make sum of the array element divisible by N, then print "-1".
Note: Using of Any STL library functions will not be acceptable. For better understanding of the above program, please go through the following samplee examples
Example input 01:
Array elements: {24,8,17,4,12} N=8
Output: 2
Explanation if you remove 17 from the array and sum remaining elements 24+8+4+12 = 48 so, 48 is divisible by 8 so, index of 17 is 2 output is 2.
Step by step
Solved in 3 steps with 1 images