I wanted to know that what is the maximum value of a[i]%a[j] in an array 'a' consisting of n elements, where 1<=i,j<=n.We have to input the value of n i.e. the no. of elements in the array and the value of each element of the array..
Why are the indices form 1 to N (inclusive)? The C++ prefers to use range 0 to N-1. Not that it matters. You can say 'k' to user and nevertheless use a[k-1].
The size of the array is determined during runtime. Hence, there is need for dynamic memory allocation. The C++ way:
1 2 3 4 5 6 7
size_t N = 0;
if ( std::cin >> N ) {
std::vector<unsignedint> a( N );
// read values
// determine largest modulo
// show result
}