Week 6: Wednesday ----------------- Q1. (40) In the main function, create an array of size 10. Input integers from the user till a negative integer is input or the 10 elements have been filled up. Save the number of valid entries of the array in a variable. Now input another integer q from the user. Write a recursive function search that checks whether q is present in the array. If q is present, it returns the index where q occurs in the array; otherwise, it returns -1. Note that you must implement the function search as a recursive function. Example: If the input is 3 15 7 89 11 1 -3 and q is 15, the program should output 1 (since a[1] = 15) If the input is 3 15 7 89 11 1 13 26 77 2 and q is 25, the program should output -1 Q2. (60) A number is called a palindrome if we get the same number on reversing the digits of that number. So, by default, all single digit numbers and especially the number 0 are palindromes. The program should take a positive integer as input and output the maximal palindrome in that number. You should first check whether the number itself is a palindrome or not. If it is not a palindrome, then strike off the first and last digits of the number and then check whether the resulting number is a palindrome. Keep doing this till you get a palindrome or the number reduces to a single digit number or 0. The resultant number is the maximal palindrome of the given number. Assume that the input number does not contain the digit 0. Your program should check whether a number is palindrome by using a recursive function: int reverse(int n) that reverses the digits of the number and returns the resulting number. Examples: 45657 is not a palindrome. So strike off the digits 4 and 7 from the number. The resultant number 565 is a palindrome, so output 565. 513347 is not a palindrome. Strike off 5,7. The resulting number is 1334 which is again not a palindrome. Strike off 1,4 and the resulting number is 33 which is a palindrome, so output that number. 1423 is not a palindrome. Strike off 1,3. Resulting number 42 is again not a palindrome. Strike off 4,2 and the number becomes 0. So, output 0 as the answer. 654 is not a palindrom. Strike off 6,4. The resulting number 5 is a single digit number which is a palindrome. Output 5. 363 is a palindrome. So, output 363 itself.