473,395 Members | 1,348 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Help in syntax void function

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<<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?
Aug 12 '07 #1
3 1518
ilikepython
844 Expert 512MB
(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.
Expand|Select|Wrap|Line Numbers
  1. void eq(int x, int y)
  2. {
  3.     d=1;
  4.     u=2;
  5.     cout<<"The value of Xd=1 and Xu=2\n";
  6.     for (i=4;i<5;i++)
  7.     {
  8.         falsi(fd,fu,fr,d,u,r)
  9.         if (fr>0 && fd>0)
  10.         {
  11.             r=d;
  12.         else
  13.             r=u;
  14. }
  15. cout<<fd<<fu<<fr<<d<<u<<r;
  16. }
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.
Expand|Select|Wrap|Line Numbers
  1. if (fr>0 && fd>0)
  2. {
  3.     r=d;
  4. else
  5.         r=u;
  6. }
The brace on that if is wrong. It should be like this:
Expand|Select|Wrap|Line Numbers
  1. if (fr > 0 && fd > 0)
  2. {
  3.     r = d;
  4. }
  5. else
  6. {
  7.     r = u;
  8. }
  9.  
You also did that in main.
Expand|Select|Wrap|Line Numbers
  1. int main
  2. {
  3.     cout<<"choose letter a, b, or c";
  4.     cin<<z;    // is this correct??
  5.     if (z==a)
  6.     {
  7.         void eq(1,2);
  8.     if(z==b)
  9.     {
  10.         void eq(2,3);
  11.     else
  12.         void eq(1,4);
  13. }
  14. }
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.
Expand|Select|Wrap|Line Numbers
  1. int main
  2. {
  3.     char z;
  4.     cout<<"choose letter a, b, or c";
  5.     cin<<z;    // is this correct??
  6.     if (z=='a')
  7.     {
  8.         eq(1,2);
  9.     }
  10.     else if (z=='b')
  11.     {
  12.         eq(2,3);
  13.     }
  14.     else
  15.     {
  16.         void eq(1,4);
  17.     }
  18. }
  19. }
Hope that helps.

PS And please put your code in code tags, it makes it easier to read.
Aug 12 '07 #2
jendrin
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
ilikepython
844 Expert 512MB
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

Sign in to post your reply or Sign up for a free account.

Similar topics

1
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...
5
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...
5
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 ) ;
3
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...
5
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,
4
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...
10
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...
2
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...
6
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...
6
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();
0
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...
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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...
0
marktang
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,...
0
jinu1996
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...
0
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...
0
tracyyun
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.