I need some help redoing this code, I want it to function a little differently than this. The code basically needs the following things: cannot use the power function, cannot use the sin function, must use header files (user defined functions), a loop must be used for factorial functions. Basically using these rules it should autmatically change the input of degrees to radians. The overall code should compute sin(x) using a taylor series expansion(using loops instead of using the factorial function) This is what I have, I know it works but I would like to change it.
I need some help redoing this code, I want it to function a little differently than this. The code basically needs the following things: cannot use the power function, cannot use the sin function, must use header files (user defined functions), a loop must be used for factorial functions. Basically using these rules it should autmatically change the input of degrees to radians. The overall code should compute sin(x) using a taylor series expansion(using loops instead of using the factorial function) This is what I have, I know it works but I would like to change it.
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
I need some help redoing this code, I want it to function a little differently than this. The code basically needs the following things: cannot use the power function, cannot use the sin function, must use header files (user defined functions), a loop must be used for factorial functions. Basically using these rules it should autmatically change the input of degrees to radians.
The overall code should compute sin(x) using a taylor series expansion(using loops instead of using the factorial function)
This is what I have, I know it works but I would like to change it.

Transcribed Image Text:#include <stdio.h>
#include<math.h>
long factorial( int);
float power(float, int);
int main(){
int n, i = 0;
float x, sum = 0;
float degrees=0;
printf("Type in Degree=>");
scanf("%f", °rees);
printf("Type in the 'n' value for Power !=>");
scanf("%d", &n);
x=(degrees) * (3.14159) / 180.0;
while(i < n){
if(i%2
e)
sum += power(x, 2*i+1)/(float) factorial(2*i+1);
else
sum
power(x,2*i+1)/(float) factorial(2*i+1);
i++;
}
printf("sin(%02.2f) is %.2f\n", degrees, sum);
getchar();
return 0;
}
float power(float x, int n)
{
float p = 1;
while(n > 0)
{
p *= x;
--n;
return p;
}
long factorial(int n)
{
if(n
== 0 || n ==
1)
return 1;
else
return n * factorial(n-1);
}
//

Transcribed Image Text:sin r
-
5!
z2n-1
El-1)(n=1)
r²n+1
or
(2n – 1)!
E(-1)"
(2n + 1)!
n=1
n=0
+
||
||
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps

Recommended textbooks for you

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education

Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY