Starting from:
$35

$29

Computer Programming Laboratory Lab # 7 Solution

    1. int check_palindrome(int a[], int n): Write a function that checks if a given array is a palindrome. The function will be called in the main function of your program. The main function will accept a set of numbers from the user. It will in turn call check_palindrome and print “Your input is a palindrome”, or “Your input is not a palindrome” depending on the output. Your check_palindrome function must be recursive. You cannot use any additional arrays in your answer.

Assume that the user cannot enter more than 50 numbers.

Hint: Palindrome is a sequence that if reversed looks identical to the original sequence. For example, {1,1,2,3,2,1,1} and {10,10} are palindromes and {1,2,4,1,2} is not.

    2. int search_element(int arr[], int input_number): Write a function that checks if an input number is in the given array and return 1 if so and 0 otherwise. You should write a simple test code as part of your main function such that a random integer array of 20 entries is generated and another random integer is sought in this array. You can generate your random numbers between 0 and 100. If you want to add different parameters for this function, it is okey. Your function must be recursive.

    3. float cos(int n, float x ): Write a function implementing the cosine of a given value using the following formula:




Write a simple test code as part of your main function. You can define MAX as a suitable number. Your function must be recursive.

More products