Question

Write a cout statement which will format and display dollars, a variable name, as: $6.00 (including...

Write a cout statement which will format and display dollars, a variable name, as: $6.00 (including the $ sign.)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:

Here is the cout statement:

cout<<"$"<<setprecision(2)<<fixed<<dollars;

Full code:

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
float dollars = 6;
  
  
cout<<"$"<<setprecision(2)<<fixed<<dollars;

return 0;
}

Output:

$6.00 ...Program finished with exit code 0 Press ENTER to exit console.

PLEASE UPVOTE IF YOU FOUND THIS HELPFUL!

PLEASE COMMENT IF YOU NEED ANY HELP!

Add a comment
Know the answer?
Add Answer to:
Write a cout statement which will format and display dollars, a variable name, as: $6.00 (including...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT