Functions and Recursions – Algebra – Problem #3

IIT Kharagpur CS10001 / CS11001 Programming and Data Structures Lab Question Archive

Difficulty: medium

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.

Back to Lab Problems
Functions and Recursions/Algebra/Problem #3

Lab Problem Statement

Specifications & Problem DetailsIIT Kharagpur PDS Archive
Loading question...

Interactive C Compiler · Problem #3

WASM In-Browser

Runs directly on your machine · Zero remote server dependency

Compiler downloads on first Run (large, saved in your browser after that)
main.cCtrl + Enter to run
1
2
3
4
5
6
7
Input (stdin)given to scanf / cin
Output

Output appears here. Press Run to compile and execute.