Last active
January 3, 2016 12:39
-
-
Save ashwani-pandey/14c1570245a2947ef053 to your computer and use it in GitHub Desktop.
wrong & right approach
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cout.precision(2); | |
cout<<fixed; | |
cout<<ans/100<<"$"<<endl;; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string res; | |
// ans was the variable containg the sum in cents | |
if(ans%100 !=0) | |
res = to_string(ans/100) + "." + to_string(ans%100) + "$"; | |
else | |
res = to_string(ans/100) + ".00$"; | |
cout<<res; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment