473,400 Members | 2,163 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,400 software developers and data experts.

syntax problems.

11
Hello i can't find the error on my program..and i dont know how to end it either.
Expand|Select|Wrap|Line Numbers
  1. #include<iostream>
  2. #include<iomanip>
  3. #include<iomanip>
  4. #include<cmath>
  5. #include<string>
  6. using namespace std;
  7.  
  8. void falsi(double& fd, double& fu, double& fr, double d, double u, double r)
  9. {
  10.    fd=sin(d)+cos(1+d*d)-1;
  11.    fu=sin(u)+cos(1+u*u)-1;
  12.    r=((u*fd - d*fu) / (fd - fu));
  13.    fr=sin(r)+cos(1+r*r)-1;
  14. }
  15.  
  16. void eq(double x, double y)
  17. {
  18.    int i;
  19.    double fd,fu,fr,u,d,r;
  20.    x*=1;
  21.    y*=1;
  22.    cout<<"The value of Xd=1 and Xu=2\n";
  23.    for (i=4;i<5;i++)
  24.    {
  25.       falsi(fd,fu,fr,d,u,r); 
  26.       if (fr > 0 && fd > 0)
  27.       {
  28.          r = d;
  29.       }
  30.       else
  31.       {
  32.          r = u;
  33.       }
  34.  
  35. int main()
  36. {
  37.    char z;
  38.    cout<<"choose letter a, b, or c";
  39.    cin>>z;   
  40.    if (z=='a')
  41.    {
  42.       eq(1,2);
  43.    }
  44.    else if (z=='b')
  45.    {
  46.       eq(1,2.5);
  47.    }
  48.    else
  49.    {
  50.       eq(1,1.5);
  51.    }
Aug 16 '07 #1
4 1095
sanctus
84
Hello i can't find the error on my program..and i dont know how to end it either.
#include<iostream>
#include<iomanip>
#include<iomanip>
#include<cmath>
#include<string>
using namespace std;




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(double x, double y)
{
int i;
double fd,fu,fr,u,d,r;
x*=1;
y*=1;
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;
}

int main()
{

char z;
cout<<"choose letter a, b, or c";
cin>>z;
if (z=='a')
{
eq(1,2);
}
else if (z=='b')
{
eq(1,2.5);
}
else
{
eq(1,1.5);
}
I don't understand why you define in falsi fd and others to be a reference to a double, but then use them in the same way a the normal doubles d, u, r.
Also what is the sense of x*=1 and y*=1? You don't change anything...
Aug 16 '07 #2
gpraghuram
1,275 Expert 1GB
Hello i can't find the error on my program..and i dont know how to end it either.
#include<iostream>
#include<iomanip>
#include<iomanip>
#include<cmath>
#include<string>
using namespace std;




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(double x, double y)
{
int i;
double fd,fu,fr,u,d,r;
x*=1;
y*=1;
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;
}

int main()
{

char z;
cout<<"choose letter a, b, or c";
cin>>z;
if (z=='a')
{
eq(1,2);
}
else if (z=='b')
{
eq(1,2.5);
}
else
{
eq(1,1.5);
}

HI,
please post the code with code tags which will be easier for us to read/understand the code.
You have couple of } missed.
Try to use a editor like notepad++ which helps u in finding this.

Raghuram
Aug 16 '07 #3
jendrin
11
What do you suggest i do?this is btw false position method for approximating a root.
Aug 16 '07 #4
Ganon11
3,652 Expert 2GB
The only syntax errors I noted were that you never finished the eq() function - there are a few }'s missing - and you also didn't finish the main() function in the same manner.
Aug 16 '07 #5

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

Similar topics

699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
303
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b....
35
by: Moosebumps | last post by:
Does anyone here find the list comprehension syntax awkward? I like it because it is an expression rather than a series of statements, but it is a little harder to maintain it seems. e.g. you...
24
by: Steven Bethard | last post by:
I think one of the biggest reasons we're having such problems coming to any agreement on decorator syntax is that each proposal makes a number of syntax decisions, not just one. For decorators, I...
29
by: shank | last post by:
1) I'm getting this error: Syntax error (missing operator) in query expression on the below statement. Can I get some advice. 2) I searched ASPFAQ and came up blank. Where can find the "rules"...
7
by: Dave | last post by:
I have 2 tables, one with names, and another with addresses, joined by their CIVICID number (unique to the ADDRESSINFO table) in Oracle. I need to update a field in the NAMEINFO table for a...
0
by: Berthold Höllmann | last post by:
I have a default coding header # -*- coding: iso-8859-15 -*- in my python files. I now have Problems with this settings. I swithched to Python 2.4.1 under Windows. When I import files with the...
8
by: tom | last post by:
I am new to SQL administration. >From a list of IDs that are the primary key in one table (i.e. Customer Table), I want to make changes in tables that use those IDs as a foreign key. ...
177
by: C# Learner | last post by:
Why is C syntax so uneasy on the eye? In its day, was it _really_ designed by snobby programmers to scare away potential "n00bs"? If so, and after 50+ years of programming research, why are...
2
by: Rick Strahl [MVP] | last post by:
I seem to have problems when working with large Windows Forms files. What happens is that hte editor looses its syntax color highlighting and Intellisense capability on large files. The code works...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.