Functions and Recursions – Algebra – Problem #3
IIT Kharagpur CS10001 / CS11001 Programming and Data Structures Lab Question Archive
Problem Statement
Write a C function readData() which does the following : Take an integer n as the input from the user The program then keeps on reading floating-point numbers from the user until the input value is within -1 < x < +1; this value is assigned to a floating-point variable x Then the program keeps on reading another set of floating-point numbers from the user until the input value is within -0.5 < a < 0.5; this value is assigned to a floating-point variable a. Now write the following two functions : findSinx(x, n) : This function takes x and n as the input, and compute sin(x) with the value of x up to n terms. Print the value of sin(x) findSinA (a) : This function takes a as the input, and compute sin(a) up to k terms such that the result is accurate up to 10-4 approximation. This indicates that the value of sin(a) remains same up to the 4 decimal position for k and (k+1) terms. Print the value of sin(a) and k (the number of terms) to achieve that value.