Flash Website Builder- Trendy Site Builder is a Flash Site Building tool that helps users build stunning websites. Check Out Custom Custom Logo Design by LogoBee. Website Design and Free Logo Templates available.
 CodingForums.com Help with simple C++ functions
 User Name Remember Me? Password

Before you post, read our: Rules & Posting Guidelines

Enjoy an ad free experience by logging in. Not a member yet? Register.
 10-24-2007, 10:49 PM PM User | #1 Derek Zoolander New Coder   Join Date: Apr 2007 Posts: 38 Thanks: 3 Thanked 0 Times in 0 Posts Help with simple C++ functions I wrote a simple program to determine the least amount of change for a given input, but I need to use a function prototype and incorporate a separate MakeChange function to perform the calculations and return the values. This is the simple program using one main function: Code: ```#include #include using namespace std; int main() { int amounttochange=1; int dollars, cents; int quarters, dimes, nickels, pennies; while(amounttochange!=0) { cout << "Enter dollar amount: "; cin >> dollars; cout << "Enter cents: "; cin >> cents; //Do calculations amounttochange = (dollars*100)+cents; //convert to cents quarters = amounttochange/25; dimes = (amounttochange%25)/10; nickels = ((amounttochange%25)%(10))/5; pennies = (((amounttochange%25)%(10)%(5)))/1; //Output coins cout << "Quarters: " << quarters < #include using namespace std; int MakeChange(double amounttochange, int quarters, int dimes, int nickels, int pennies); int main(?) //do i need any parameters here? { while(double amounttochange!=0) { cout << "Enter the amount to change (enter 0 to end program): "; cin >> amounttochange; cout << "Quarters: " << MakeChange(?) <
 10-25-2007, 05:37 AM PM User | #2 ralph l mayo Regular Coder     Join Date: Nov 2005 Posts: 951 Thanks: 1 Thanked 31 Times in 29 Posts There are several ways to do this, returning a pointer to an array being among the least preferable. The instructor/text is probably hoping to see you use a struct: Code: ```struct Change { int quarters, dimes, nickles, pennies; }; Change MakeChange(double amt);```
 10-25-2007, 05:51 AM PM User | #3 oracleguy Rockstar Coder   Join Date: Jun 2002 Location: USA Posts: 9,054 Thanks: 1 Thanked 322 Times in 318 Posts You could also pass the quarters, dimes, nickel (you could never have more than 1 nickel) and pennies by reference to your MakeChange function. __________________ OracleGuy

 Bookmarks

 Thread Tools Rate This Thread Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home :: Client side development     JavaScript programming         DOM and JSON scripting         Ajax and Design         JavaScript frameworks         Post a JavaScript     HTML & CSS     XML     Flash & ActionScript         Adobe Flex     Graphics and Multimedia discussions     General web building         Site reviews         Building for mobile devices :: Server side development     Apache configuration     Perl/ CGI     PHP         Post a PHP snippet     MySQL         Other Databases     Ruby & Ruby On Rails     ASP     ASP.NET     Java and JSP     Other server side languages/ issues         ColdFusion         Python :: Computing & Sciences     Computer Programming     Computer/PC discussions     Geek News and Humour Web Projects and Services Marketplace     Web Projects         Small projects (quick fixes and changes)         Medium projects (new script, new features, etc)         Large Projects (new web application, complex features etc)         Unknown sized projects (request quote)         Vacant job positions         Looking for work/ for hire         Project collaboration/ partnership         Paid work offers and requests (Now CLOSED)     Career, job, and business ideas or advice     Domains, Sites, and Designs for sale         Domains for sale         Websites for sale         Design templates and graphics for sale :: Other forums     Member Offers     Forum feedback and announcements

All times are GMT +1. The time now is 10:25 PM.