WhenKittensATK Posted December 3, 2008 Posted December 3, 2008 (edited) solved Edited June 22, 2013 by AZNguyen Quote Share this post Link to post Share on other sites More sharing options...
flareback Posted December 3, 2008 Posted December 3, 2008 I realize that's not all the code but is there a reason outputresults returns a double? if it is simply printing out the parameters it's passed why not just return a void. Or if you are returning something just to show it ran correctly why not an int? anyways, glad you figured it out. Quote Share this post Link to post Share on other sites More sharing options...
Waco Posted December 3, 2008 Posted December 3, 2008 First off, main should be above all other functions (especially since you're calling those functions from main). Second, the function should have a return type of void since it does nothing other than print out junk and return nothing. Last - just think about what variables your function will need and pass them by value (like you did above). Guessing randomly is no way to learn how to program. Quote Share this post Link to post Share on other sites More sharing options...
DLS2008 Posted December 3, 2008 Posted December 3, 2008 Although it's not a huge issue in this case, your outputResult function should have been a void as stated above. It doesn't return any values, why should it be a double? Also, there's no issue with putting you function above main, but good formatting has you declare the functions above main, but fill them in below main. You'd have: double outputResult(blah blah) main() { blah blah } double outputResult(blah blah) { blah blah } Again, not important here, but you should pass the values by reference from main into outputResult. In this program it doesn't matter, but in larger programs it's a way to conserve memory space. Quote Share this post Link to post Share on other sites More sharing options...
WhenKittensATK Posted December 3, 2008 Posted December 3, 2008 I started this assigment 1hour before it was due, the lecture it self was over an hour. I really didn't want to spin any time doing it. Thats why I randomly plugged it in. I had it void at first, not sure why I changed it. Note this is only a concepts class and he really didn't go into detail. When he was doing the lecture he just did the main function first, then decomposed all his variables in functions above the main function. Thank you for letting me know that functions go in the main() then declaring it above. Programming is trail and error, plugging thing randomly some times works and you learn how to do it from that. Newbie programmers aren't going to get their programs running 100% on the first write down. Tweaks will be made, editing will be done. I just didn't have any time for that since I alreadly passed the the due time which was 11pm and I turned it in about 12:45 am. Quote Share this post Link to post Share on other sites More sharing options...
flareback Posted December 3, 2008 Posted December 3, 2008 Note this is only a concepts class and he really didn't go into detail. When he was doing the lecture he just did the main function first, then decomposed all his variables in functions above the main function. Thank you for letting me know that functions go in the main() then declaring it above. The functions don't go in main, they were saying to put them below main, big difference. Just trying to help out the terminology. I hope you don't think we're being punks either. We really are trying to help because these things are important. It's good to get good techniques early on rather than trying to change things later. Quote Share this post Link to post Share on other sites More sharing options...
WhenKittensATK Posted December 3, 2008 Posted December 3, 2008 No I take your constructive feedback like a pro. Sorry, I misread it. Was reading it early in the morning when I just woke up. Thanks for the correction. I was just letting you guys know the limitations of what I was being taught/knew Quote Share this post Link to post Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.