C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #16  
Old October 25th, 2009, 04:01 PM
sizablegrin's Avatar
sizablegrin sizablegrin is offline
Crab
Click here for more information.
 
Join Date: Jun 2005
Posts: 5,783 sizablegrin User rank is General 53rd Grade (Above 100000 Reputation Level)sizablegrin User rank is General 53rd Grade (Above 100000 Reputation Level)sizablegrin User rank is General 53rd Grade (Above 100000 Reputation Level)sizablegrin User rank is General 53rd Grade (Above 100000 Reputation Level)sizablegrin User rank is General 53rd Grade (Above 100000 Reputation Level)sizablegrin User rank is General 53rd Grade (Above 100000 Reputation Level)sizablegrin User rank is General 53rd Grade (Above 100000 Reputation Level)sizablegrin User rank is General 53rd Grade (Above 100000 Reputation Level)sizablegrin User rank is General 53rd Grade (Above 100000 Reputation Level)sizablegrin User rank is General 53rd Grade (Above 100000 Reputation Level)sizablegrin User rank is General 53rd Grade (Above 100000 Reputation Level)sizablegrin User rank is General 53rd Grade (Above 100000 Reputation Level)sizablegrin User rank is General 53rd Grade (Above 100000 Reputation Level)sizablegrin User rank is General 53rd Grade (Above 100000 Reputation Level)sizablegrin User rank is General 53rd Grade (Above 100000 Reputation Level)sizablegrin User rank is General 53rd Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 3 Weeks 11 h 24 m 8 sec
Reputation Power: 4482
You actually have to know what you are doing. No instructor and no good grade can guarantee that. Only thinking well can guarantee that. If that doesn't fit your profile, you should look for another field. The programming ranks are already filled with costly failures.
__________________
Write no code whose complexity leaves you wondering what the hell you did.
Politically Incorrect DaWei on Pointers Grumpy on Exceptions

Reply With Quote
  #17  
Old October 25th, 2009, 04:06 PM
jacus jacus is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Posts: 15 jacus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 42 m 5 sec
Reputation Power: 0
What the hell are you talking about? I've already posted a question.

Reply With Quote
  #18  
Old October 25th, 2009, 04:13 PM
sizablegrin's Avatar
sizablegrin sizablegrin is offline
Crab
Click here for more information.
 
Join Date: Jun 2005
Posts: 5,783 sizablegrin User rank is General 53rd Grade (Above 100000 Reputation Level)sizablegrin User rank is General 53rd Grade (Above 100000 Reputation Level)sizablegrin User rank is General 53rd Grade (Above 100000 Reputation Level)sizablegrin User rank is General 53rd Grade (Above 100000 Reputation Level)sizablegrin User rank is General 53rd Grade (Above 100000 Reputation Level)sizablegrin User rank is General 53rd Grade (Above 100000 Reputation Level)sizablegrin User rank is General 53rd Grade (Above 100000 Reputation Level)sizablegrin User rank is General 53rd Grade (Above 100000 Reputation Level)sizablegrin User rank is General 53rd Grade (Above 100000 Reputation Level)sizablegrin User rank is General 53rd Grade (Above 100000 Reputation Level)sizablegrin User rank is General 53rd Grade (Above 100000 Reputation Level)sizablegrin User rank is General 53rd Grade (Above 100000 Reputation Level)sizablegrin User rank is General 53rd Grade (Above 100000 Reputation Level)sizablegrin User rank is General 53rd Grade (Above 100000 Reputation Level)sizablegrin User rank is General 53rd Grade (Above 100000 Reputation Level)sizablegrin User rank is General 53rd Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 3 Weeks 11 h 24 m 8 sec
Reputation Power: 4482
I'm talking about for real. You're talking about faking it with limited knowledge.

Reply With Quote
  #19  
Old October 25th, 2009, 04:16 PM
jacus jacus is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Posts: 15 jacus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 42 m 5 sec
Reputation Power: 0
OK.

If anyone feels that they can help me with my program, I'll appreciate it.

Reply With Quote
  #20  
Old October 25th, 2009, 04:22 PM
Nyan Nyan is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2009
Posts: 230 Nyan Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 3 Days 20 h 27 m 12 sec
Reputation Power: 0
Isn't your code working ? I think you forgot that the sign is altering. ?

Reply With Quote
  #21  
Old October 25th, 2009, 04:23 PM
jacus jacus is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Posts: 15 jacus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 42 m 5 sec
Reputation Power: 0
Yes, it is.

Do you mean switching
Code:
element=(sin(n*x))/pow(n,3);
to
Code:
element=(sin(n*x)*pow(-1,n))/pow(n,3);
?

Reply With Quote
  #22  
Old October 25th, 2009, 04:32 PM
Nyan Nyan is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2009
Posts: 230 Nyan Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 3 Days 20 h 27 m 12 sec
Reputation Power: 0
You are incrementing n before calculating element. Shouldn't it be after ?

Reply With Quote
  #23  
Old October 25th, 2009, 04:38 PM
jacus jacus is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Posts: 15 jacus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 42 m 5 sec
Reputation Power: 0
Yep. So switch
Code:
n=n+1;
    element=(sin(n*x))/pow(n,3);

to
Code:
element=(sin(n*x))*pow(-1,n)/pow(n,3);
n=n+1;
?

Reply With Quote
  #24  
Old October 25th, 2009, 05:25 PM
jwdonahue's Avatar
jwdonahue jwdonahue is offline
Bellevue WA, USA
Click here for more information.
 
Join Date: May 2004
Location: Bellevue Washington, USA
Posts: 2,530 jwdonahue User rank is Colonel (50000 - 60000 Reputation Level)jwdonahue User rank is Colonel (50000 - 60000 Reputation Level)jwdonahue User rank is Colonel (50000 - 60000 Reputation Level)jwdonahue User rank is Colonel (50000 - 60000 Reputation Level)jwdonahue User rank is Colonel (50000 - 60000 Reputation Level)jwdonahue User rank is Colonel (50000 - 60000 Reputation Level)jwdonahue User rank is Colonel (50000 - 60000 Reputation Level)jwdonahue User rank is Colonel (50000 - 60000 Reputation Level)jwdonahue User rank is Colonel (50000 - 60000 Reputation Level)jwdonahue User rank is Colonel (50000 - 60000 Reputation Level)jwdonahue User rank is Colonel (50000 - 60000 Reputation Level)jwdonahue User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 2 Weeks 5 Days 11 h 58 m 20 sec
Reputation Power: 603
Because you are using pow(), you should probably use doubles, not floats. Other than that and the inconsistent use of indentation, it looks like you got most of the algorithm down. I just have one question regarding this loop conditional:

(element > 1e-8 || element < -1e-8)

What is the meaning of (element == 1e-8 || element == -1e-8) ? I am not saying this is wrong, I was just wondering what logic led you to use these magic numbers to terminate your loop?
__________________
My worst nightmare was a pointless infinite loop.
Work in progress; don't poke the curmudgeon!
http://www.odonahue.com/

Reply With Quote
  #25  
Old October 25th, 2009, 05:44 PM
jacus jacus is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Posts: 15 jacus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 42 m 5 sec
Reputation Power: 0
Quote:
Originally Posted by jwdonahue
(element > 1e-8 || element < -1e-8)


To be frankly - I have no idea.

On the beginning, I had just the first part, but then I've shown this code to some experienced guy who works as a programmmer. By the time I realized that change he made, he has already been away.

You're talking about inconsistent use of paragraphs and brackets. Could you (or maybe someone else) point me out what exactly should I improve?

Reply With Quote
  #26  
Old October 25th, 2009, 08:05 PM
jacus jacus is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Posts: 15 jacus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 42 m 5 sec
Reputation Power: 0
Do you have any idea why this program isn't working for x=3 or x=-3?

Reply With Quote
  #27  
Old October 26th, 2009, 04:02 AM
jwdonahue's Avatar
jwdonahue jwdonahue is offline
Bellevue WA, USA
Click here for more information.
 
Join Date: May 2004
Location: Bellevue Washington, USA
Posts: 2,530 jwdonahue User rank is Colonel (50000 - 60000 Reputation Level)jwdonahue User rank is Colonel (50000 - 60000 Reputation Level)jwdonahue User rank is Colonel (50000 - 60000 Reputation Level)jwdonahue User rank is Colonel (50000 - 60000 Reputation Level)jwdonahue User rank is Colonel (50000 - 60000 Reputation Level)jwdonahue User rank is Colonel (50000 - 60000 Reputation Level)jwdonahue User rank is Colonel (50000 - 60000 Reputation Level)jwdonahue User rank is Colonel (50000 - 60000 Reputation Level)jwdonahue User rank is Colonel (50000 - 60000 Reputation Level)jwdonahue User rank is Colonel (50000 - 60000 Reputation Level)jwdonahue User rank is Colonel (50000 - 60000 Reputation Level)jwdonahue User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 2 Weeks 5 Days 11 h 58 m 20 sec
Reputation Power: 603
Quote:
Originally Posted by jacus
Do you have any idea why this program isn't working for x=3 or x=-3?


You might start by defining what "isn't working" means.

Reply With Quote
  #28  
Old October 31st, 2009, 06:07 PM
jacus jacus is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Posts: 15 jacus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 42 m 5 sec
Reputation Power: 0
When I run the program, enter 3, it returns 'Enter the value of x. It must be between -pi and pi'.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > [C] sum of the series - loop?


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




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

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




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek