Exforsys

Free Training

got some error on the PrintResult,,tell me how to change it!

This is a discussion on got some error on the PrintResult,,tell me how to change it! within the C and C++ forums, part of the Programming Talk category; #include <stdio.h> int main(); int getData() { int totalChange; printf("Please enter amount of change:"); scanf("%d", &totalChange); return(totalChange); } int errorResult(int ...

Go Back   Exforsys > Programming Talk > C and C++

Exforsys.com


C and C++ C and C++

Reply

 

LinkBack Thread Tools Search this Thread
  #1 (permalink)  
Old 04-08-2009, 12:44 PM
Junior Member
 
Join Date: Apr 2009
Posts: 4
vc_15 is on a distinguished road
got some error on the PrintResult,,tell me how to change it!

#include <stdio.h>

int main();

int getData()
{
int totalChange;
printf("Please enter amount of change:");
scanf("%d", &totalChange);

return(totalChange);
}

int errorResult(int totalChange)
{
const int MaxChange = 95;
const int MinChange = 5;

int valid;

if(totalChange > MaxChange || totalChange < MinChange)
{
printf("Please enter the number between 5 and 95: \n");
valid = 0;

}
return(valid);
}


float makeChange(int *totalChange, int cent)
{
int number = 0;
int newChange;
float change;
int dollar;
int cents;

newChange =(*totalChange % cent);
number =(*totalChange - newChange)/cent;
*totalChange = newChange;

dollar = (int) change;
cents = (int) (((change - dollar)*100) + 0.5);

return(number);
}


void PrintResult(int number, int cents, int Dollar)
{
printf("%dc = %d\n", Dollar, number);

return;

}


int main()
{
int totalChange, fiftyc, twentyc, tenc, fivec, valid;
int hundredd, fiveZerod, twoZerod, oneZerod, ZeroFived, ZeroTwod, ZeroOned;


const int FiftyCents = 50;
const int TwentyCents = 20;
const int TenCents = 10;
const int FiveCents = 5;
const int HundredDollars = 100;
const int FiveZeroDollars = 50;
const int TwoZeroDollars = 20;
const int OneZeroDollars = 10;
const int zeroFiveDollars = 5;
const int zeroTwoDollars = 2;
const int zeroOneDollars = 1;

totalChange = getData();
valid = errorResult(totalChange);
if(valid)
{
fiftyc = makeChange(&totalChange, FiftyCents);
twentyc = makeChange(&totalChange, TwentyCents);
tenc = makeChange(&totalChange, TenCents);
fivec = makeChange(&totalChange, FiveCents);
hundredd = makeChange(&totalChange, HundredDollars);
fiveZerod = makeChange(&totalChange, FiveZeroDollars);
twoZerod = makeChange(&totalChange, TwoZeroDollars);
oneZerod = makeChange(&totalChange, OneZeroDollars);
ZeroFived = makeChange(&totalChange, zeroFiveDollars);
ZeroTwod = makeChange(&totalChange, zeroTwoDollars);
ZeroOned = makeChange(&totalChange, zeroOneDollars);

PrintResult(makeChange(totalChange, FiftyCents), FiftyCents);
PrintResult(makeChange(totalChange, TwentyCents), TwentyCents);
PrintResult(makeChange(totalChange, TenCents), TenCents);
PrintResult(makeChange(totalChange, FiveCents), FiveCents);
PrintResult(makeChange(totalChange, HundredDollars), HundredDollars);
PrintResult(makeChange(totalChange, FiveZeroDollars), FiveZeroDollars);
PrintResult(makeChange(totalChange, TwoZeroDollars), TwoZeroDollars);
PrintResult(makeChange(totalChange, OneZeroDollars), OneZeroDollars);
PrintResult(makeChange(totalChange, zeroFiveDollars), zeroFiveDollars);
PrintResult(makeChange(totalChange, zeroTwoDollars), zeroTwoDollars);
PrintResult(makeChange(totalChange, zeroOneDollars), ZerOneDollars);
}


return(0);

}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 04-08-2009, 01:05 PM
Junior Member
 
Join Date: Apr 2009
Posts: 4
vc_15 is on a distinguished road
reply

please reply it!! i just want to know whats my mistake
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
Top 5 Reasons Why You Need a Career Change lokeshm Career Advice 0 01-31-2007 06:19 AM
Change Password for SQL Server User admin SQL Server 2005 Tutorials 2 04-07-2006 12:09 PM
Solaris x86 FAQ 2/2 Dan Anderson Tech FAQ 0 04-27-2004 08:24 PM
Quarterly ASCII posting of Caldera (SCO) OpenUNIX 8 FAQ Boyd Lynn Gerber Tech FAQ 0 04-25-2004 11:11 PM
Kerberos FAQ, v2.0 (last modified 8/18/2000) Ken Hornstein Tech FAQ 0 04-17-2004 08:28 AM


All times are GMT -4. The time now is 08:58 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0
Copyright 2004 - 2009 Exforsys Inc. All rights reserved.