C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old February 4th, 2013, 08:59 AM
hbhans hbhans is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 1 hbhans User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 m 41 sec
Reputation Power: 0
Unhappy Syntax errors - Initialization

I am trying to compile the following C++ program using CodeBlocks:

#include<iostream>
using namespace std;

double function f(double x)
{
return 1 + x*(24 + x*(-50 + x*(35 + x*(-140 + x))));
};
double function fdash(double x)
{
return 24 + x*(-100 + x*(105 + x*(-40 + 5*x)));
};
double function Newton(double x0,double tol)
{
double x = x0; double incr = 1000;
while (abs(incr) > tol)
{
incr = f(x)/fdash(x);
x = x - incr;
} ;
return x;
};
int main()
{
double x0 = 0.2;
cout << Newton(x0,0.00001)<< endl;
return 0;
};

but get the following error messages:

line 4 error: expected initializer before 'f'
line 8 error: expected initializer before 'fdash'
line 12 error: expected initializer before 'Newton'

Can anybody help? What am I doing wrong?

Reply With Quote
  #2  
Old February 21st, 2013, 09:02 AM
dev20111 dev20111 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 1 dev20111 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 m 50 sec
Reputation Power: 0
You need to delete ; after every function. And function key word. This is not c++ syntax

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > Syntax errors - Initialization


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

© 2003-2014 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap