RSS Forums RSS
Please support our C++ advertiser: Programming Forums

Pass by reference in Function call results not correct

Join Date: Oct 2007
Posts: 7
Reputation: pyramid is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
pyramid pyramid is offline Offline
Newbie Poster

Re: Pass by reference in Function call results not correct

  #4  
Oct 19th, 2007
My codes works great . No more errors. Thank you guys for all the suggestions.

I removed line 57 & 58. I thought that I had to do this to pass the value, but what I needed to do was just call my calc function. I agree with the revision to the calc body function. The original equation given to the class was: area = sqrt (s*(s-a)*(s-b)*(s-c)); I originally had this as one line, but changed it later. I agree that one line is better than three lines and much neater too.

I couldn’t agree more about solving the problems by hand first. I had actually done this for test data 5, 8, 12 (see below)

5 + 8+ 12 = 25.00 perimeter
25 /2.0 = 12.50
12.50 – 5 = 7.50
12.50 – 8 = 4.50
12.50 – 12 =.50
7.50 * 4.50 * .50 = 16.88
12.50 * 16.88 = 211
sqrt (211) = 14.525839 area

I changed the code to divide by 2.0 (I always forget to do double). Lastly, I created a new variable ‘perimeter’ to store the perimeter value. And result of ‘s’ is stored in ‘s’.

I continuously learn from you guys – keep up the great job you’re doing. It’s awesome that people are so willing to help each other….

Thanks again.
Reply With Quote  
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 2:17 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC