434,720 Members | 2,145 Online + Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,720 IT Pros & Developers. It's quick & easy.

Help in syntax void function

 P: 11 (Regula falsi metod. To calculate the root using 4 iterations) I need the user to pick from problem a, b or c wherein every problem has different initial guesses.ex( prob. a Xd=1 Xu=2, prob. b Xd=2 Xu=3) same process for all problems. And also i want to show all the values of Xd,Xu,Xr,d,u,r for the 4 iterations in tabular form.What i have done so far is this: void falsi(double& fd, double& fu, double& fr, double d, double u, double r) { fd=sin(d)+cos(1+d*d)-1; fu=sin(u)+cos(1+u*u)-1; r=((u*fd - d*fu) / (fd - fu)); fr=sin(r)+cos(1+r*r)-1; } void eq(int x, int y) { d=1; u=2; cout<<"The value of Xd=1 and Xu=2\n"; for (i=4;i<5;i++) { falsi(fd,fu,fr,d,u,r) if (fr>0 && fd>0) { r=d; else r=u; } cout<
3 Replies

 Expert 100+ P: 844 (Regula falsi metod. To calculate the root using 4 iterations) I need the user to pick from problem a, b or c wherein every problem has different initial guesses.ex( prob. a Xd=1 Xu=2, prob. b Xd=2 Xu=3) same process for all problems. And also i want to show all the values of Xd,Xu,Xr,d,u,r for the 4 iterations in tabular form.What i have done so far is this: void falsi(double& fd, double& fu, double& fr, double d, double u, double r) { fd=sin(d)+cos(1+d*d)-1; fu=sin(u)+cos(1+u*u)-1; r=((u*fd - d*fu) / (fd - fu)); fr=sin(r)+cos(1+r*r)-1; } void eq(int x, int y) { d=1; u=2; cout<<"The value of Xd=1 and Xu=2\n"; for (i=4;i<5;i++) { falsi(fd,fu,fr,d,u,r) if (fr>0 && fd>0) { r=d; else r=u; } cout<0 && fd>0)         {             r=d;         else             r=u; } cout<0 && fd>0) {     r=d; else         r=u; } The brace on that if is wrong. It should be like this: Expand|Select|Wrap|Line Numbers if (fr > 0 && fd > 0) {     r = d; } else {     r = u; }   You also did that in main. Expand|Select|Wrap|Line Numbers int main {     cout<<"choose letter a, b, or c";     cin<

 P: 11 thx so much phython! sorry i'm just new here and i dont know how to create tags.. what about void(int x,int y)? i didn't quite understand whats wrong with it..can you clear it up more?thx so much again!! btw, will this program work? Aug 12 '07 #3

 Expert 100+ P: 844 thx so much phython! sorry i'm just new here and i dont know how to create tags.. what about void(int x,int y)? i didn't quite understand whats wrong with it..can you clear it up more?thx so much again!! btw, will this program work? The code tags are just [ c o d e = c p p ] [ / c o d e ] without the spaces. Your function takes two integers, x, and y. You never use them in the function. What are you trying to do? Aug 12 '07 #4 