(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<<fd<<fu<<fr<<d<<u<<r;
}
int main
{
cout<<"choose letter a, b, or c";
cin<<z; // is this correct??
if (z==a)
{
void eq(1,2);
if(z==b)
{
void eq(2,3);
else
void eq(1,4);
}
}
// Is this correct?
Btw, where can i download MSdev C++ version 5.0?
3 1518
(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<<fd<<fu<<fr<<d<<u<<r;
}
int main
{
cout<<"choose letter a, b, or c";
cin<<z; // is this correct??
if (z==a)
{
void eq(1,2);
if(z==b)
{
void eq(2,3);
else
void eq(1,4);
}
}
// Is this correct?
Btw, where can i download MSdev C++ version 5.0?
You have some syntax errors. - 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<<fd<<fu<<fr<<d<<u<<r;
-
}
You call falsi with fd, fu, fr, u, and r, but you never declared fd, fu ,fr, or r. Also, you never use x and y which are passed into the function. - if (fr>0 && fd>0)
-
{
-
r=d;
-
else
-
r=u;
-
}
The brace on that if is wrong. It should be like this: -
if (fr > 0 && fd > 0)
-
{
-
r = d;
-
}
-
else
-
{
-
r = u;
-
}
-
You also did that in main. - int main
-
{
-
cout<<"choose letter a, b, or c";
-
cin<<z; // is this correct??
-
if (z==a)
-
{
-
void eq(1,2);
-
if(z==b)
-
{
-
void eq(2,3);
-
else
-
void eq(1,4);
-
}
-
}
You never declared 'z' when you use it with cin. Also, you are checking z with the variable 'a'. You want to check it against the value 'a'. Also, you are calling your functions wrong. Delete the void before the call. - int main
-
{
-
char z;
-
cout<<"choose letter a, b, or c";
-
cin<<z; // is this correct??
-
if (z=='a')
-
{
-
eq(1,2);
-
}
-
else if (z=='b')
-
{
-
eq(2,3);
-
}
-
else
-
{
-
void eq(1,4);
-
}
-
}
-
}
Hope that helps.
PS And please put your code in code tags, it makes it easier to read.
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?
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?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Piotre Ugrumov |
last post by:
in this simulation I have implemented 4 classes, a class Animal(Animale),
the classes Lion(Leone) and Zebra.
A Lion died after 100000 iteration if he don't eat a zebra.
If the distance between the...
|
by: Danny Anderson |
last post by:
Hola-
I didn't get any responses on a previous post, so I am trying to reword my
problem and post compile-able code that exhibits the behavior I am
describing.
On the second iteration of the...
|
by: xuatla |
last post by:
Hi,
I have the following code for function pointer. compiling is ok. Can you
help me to check whether it's a good way to implement as:
class CA
{
.....
private:
void f1( double ) ;
|
by: Thomas Matthews |
last post by:
Hi,
At my work, we have a need for a pointer to a pointer
to a function returning void and having void parameters.
Since this is an embedded system, we have to assign the
variable with a...
|
by: damian birchler |
last post by:
What's wrong about this:
22: static void (*)(void) instruction_table = {
jnz,
halt,
mv,
add,
mul,
mv_reg,
add_reg,
|
by: winnerpl |
last post by:
Hey guys I'm trying to get a magic square but I'm stuck with it printing
out only 1's and 0's in random places. Hope you experts can can provide
some input on what I'm doing wrong.
#include...
|
by: Adam Warner |
last post by:
Hi all,
Just before Christmas Chris Torek gave me some great advice about closures in C:
<http://groups.google.co.nz/groups?selm=cqcl3k030vj%40news3.newsguy.com&output=gplain>
It includes this...
|
by: Erik |
last post by:
Hi Everyone,
I'm having real problems compiling some source for eVC4++. The errors
I am getting are below:
It all seems to be centred around winsock. If I move the afsock.h
reference to before...
|
by: toch3 |
last post by:
i am writing a c program that is basically an address book. the only
header we are using is #include<stdio.hwe are to use a global array,
loops, and pointers. we are to have a menu at the...
|
by: priyajohal |
last post by:
#include<fstream.h>
#include<process.h>
#include<stdlib.h>
#include<conio.h>
#include<string.h>
#include<dos.h>
#include<ctype.h>
#include<stdio.h>
void setup()
void help();
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |