Laboratory Test I
(Section : 2)
For students with odd PC numbers
1.Write a program that
takes as input from the user an angle
x in
degrees (-90° ≤
x ≤ 90°) and an integer N (1
≤N ≤ 1000) and prints the value of
sin(x),
by adding the first N
terms in its series expansion:
First convert degree into radians (the value of x in the power series is in radians). You can use macro M_PI, where approximate value of П is defined. For this purpose, you must include math.h
Also print the value of sin(x) using the standard library function.
TEST CASES:
x | N | Sin(x) |
180° | 500 | Incorrect input |
45° | 3 | 0.707143 |
45° | 100 | 0.707107 |
75° | 10 | 0.965926 |
90° | 10 | 1.000003 |
[MARKS :12]
2. Write a program that prints the largest 4 digit prime number.
For students with even PC numbers
1. Write a program that reads the value of x (real
number, | x| <1) and a integer
N (1 ≤N ≤ 1000) and prints the value of
log(1 + x),
by adding the first N
terms in its series expansion:
Also print the value of log(1+x) using the standard library function. For
this purpose, you must include math.h
TEST CASES:
x | N | log(1+x) |
-2 | 100 | incorrect input |
0.2 | 1000 | 0.182322 |
0.7 | 10 | 0.529532 |
0.7 | 500 | 0.530628 |
[MARKS :12]
2. Write a program to find the prime factors of a given number N.
TEST CASES:
Input(N) | Prime factors |
-8 | incorrect input |
10 | 2, 5 |
36 | 2, 3 |
420 | 2 , 3, 5, 7 |
[MARKS :08]