# Use the non-recursive method to calculate the sin value of radians (implemented in c) using the Taylor series

Source: Internet
Author: User
This is also for a friend who loves to ask. I don't know if there is any better way.

# Include <stdio. h>
# Include <math. h>
# Define ex 0.000001
Int main ()
...{
Double X = 0.0, temp = 1.0, sin = 0.0;
Int I;

Printf ("Please input a degree :");
Scanf ("% lf", & X );
Temp = X;
I = 0;
While (FABS (temp)> ex )...{
Sin + = temp;
I + = 2;
Temp = (-1) * temp * x/(I + 1) * (I ));
}

Printf ("Sin (% lf) = % lf", X, sin );
Printf ("the number is % d", I );
Return 0;
}

Answers to another question under the same question
Q: M = 2/1*2/3*4/3*4/5*6/5*6/7 *... use a loop to obtain the first one hundred values of M.

# Include <stdio. h>
Int main ()
...{
Double M = 1.0;
Double X = 2.0, y = 1.0;
Int I = 0;
For (I = 0; I <100; ++ I )...{
M * = x/y;
If (I % 2 = 0 )...{
Y + = 2;
}
Else ...{
X + = 2;
}
}
Printf ("% lf", M );
Return 0;
}

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.