As I saw an example in tutorial 25, in a printf statement, the dollar sign was used. What does it stand for ?
printf(" Day: %d /t Amount : $ .2%f \n", day, amount);
What does $ sign stands for ?
Post a Reply
|Oldest Newest Rating|
· January 18, 2016
You appear to have misplaced the % character in ".2%f". I think you meant "%.2f". Note that I'm not referring to the dollar character ($); I'm referring to the percent symbol.
The dollar character is meaningless in C. In fact, it's not even in the C standard. If it's possible that your code might execute on machines that don't have this character, you should probably find a different symbol...
In fact, it'd probably be a good idea to just use the currency symbol you're referring to as it appears in the stock market. For example, your printf statement should probably look like this, if you're talking about US dollars:
printf(" Day: %d /t Amount : %.2f USD\n", day, amount);
... or if you want to continue to use the $ sign:
printf(" Day: %d /t Amount : $ %.2f \n", day, amount);
P.S. It's unusual to use float or double for currencies due to rounding errors.
· January 17, 2016
You are confusing % with $.
One of the most popular languages of all time.
|Bucky Roberts Administrator|