Single File Programming Question
Problem Statement
John wants to find the maximum difference between two elements in an array using pointers. He wants to write a program that takes an array as input and calculates the maximum difference between any two elements in the array.
Guide him with the code.
Function Specifications: int maxDiff(int *, int )
Input format :
The first line of input consists of an integer N, representing the number of elements in the array.
The second line consists of N space-separated integers, representing the elements of the array.
Output format :
The output displays an integer, representing the maximum difference between any two elements in the array.
Refer to the sample output for formatting specifications.
Code constraints :
2 ≤ N ≤ 30
-106 ≤ array elements ≤ 106
Sample test cases :
Input 1 :
5 1 10 12 15 30
Output 1 :
29
Input 2 :
5 20 0 60 80 25
Output 2 :
80