Driver program to test above function
int main ( ) { int set1 [ ] = { 1 , 7 , 10 , 13 , 14 , 19 } ; int n1 = sizeof ( set1 ) / sizeof ( set1 [ 0 ] ) ; cout << lenghtOfLongestAP ( set1 , n1 ) << endl ; int set2 [ ] = { 1 , 7 , 10 , 15 , 27 , 29 } ; int n2 = sizeof ( set2 ) / sizeof ( set2 [ 0 ] ) ; cout << lenghtOfLongestAP ( set2 , n2 ) << endl ; int set3 [ ] = { 2 , 4 , 6 , 8 , 10 } ; int n3 = sizeof ( set3 ) / sizeof ( set3 [ 0 ] ) ; cout << lenghtOfLongestAP ( set3 , n3 ) << endl ; return 0 ; }