User Profile
Collapse
-
Yeah, I prefer to do the programs on my own and try to figure them out, but this one had stumpped me for a few days. I have been slowly realizing stuff and piecing them together. The help you have provided has been good also. I figured out one problem as to why I wasn't getting the right number. I plugged a wrong variable into the equation. The number is a little off but I think it has to do with how many digits I defined PI to. Thanks for all the... -
I changed the for loop to end at the end of the program, but it's still doing the same thing. When I compile and build it shows no errors or warnings. Let me know if I'm missing something about the debugging. I will try to do another program with only one.Leave a comment:
-
No, I don't get a runtime error. No matter what number I type in when I run it, it returns the value 1 for what sine equals. Unless I type 0 then it stops.Leave a comment:
-
Both ends are the same now. I'm still having trouble getting the right number though. It always gives me 1 as my sine.
Code:#include <iostream> #include <math.h> using namespace std; #define PI 3.14 int main() { float angle,radian,sine,n,x,factorial,s,i; x=1; for (i=1;i<=15;i++){ factorial=factorial*1; }
Leave a comment:
-
-
I don't understand what you mean with the //priming thing. When I try to compile this one it only lets me find one sine, instead of going until 0 is entered like it is supposed to. Here is what I have now though:
Code:#include <iostream> #include <math.h> using namespace std; #define PI 3.14 int main() { float angle,radian,sine,n,x,factorial,s,i; x=1;
Leave a comment:
-
I finally have the program able to read out what sin equals. The problem is the it is giving me the wrong number. I have a feeling it is because of the "n" in the equation needs to be the factorial here. Here is what I have now:
Code:#include <iostream> #include <math.h> using namespace std; #define PI 3.14 int main() { float angle,radian,sine,n,x,factorial;
Leave a comment:
-
Ok I will look at that stuff. In case this helps, this is the actual problem that I'm using and trying to solve.
The value of sin(x) can be approximated by using the formula:
sin(x) = x −
x3
3!
+
x5
5!
−
x7
7!
+
x9
9!
· · ·
where x is an angle in radians. Using the formula, approximate the value of the
sine of an angle (in...Leave a comment:
-
-
I'm not really sure if the factorial works. That was one part that I thought might be wrong. I have been drawing a blank on how to make the factorial work for a while, even though I did one like a month ago.Leave a comment:
-
Value of sin problem
I am trying to get the value of sin based on an angle input from the user. The program changes the angle from degrees to radians. Then uses the formula:
sin(x) = x − x^3/3! + x^5/5! - x^7/7! + x^9/9!...
It does this all the way to 15. When I try to compile my program it says it doesn't evaluate to a function. Here is what I have so far:
Code:#include <iostream> #include <math.h> using namespace std;
No activity results to display
Show More
Leave a comment: