Answer to Question #159553 in C++ for Earl

Question #159553

Practice basic output formatting by reproducing the output below. All floating-point numbers should have 3 decimal places. Use these constants and values: NUM1= 10, NUM2= 1.49, and NUM3= 12.538767

 

Output:

  NUM1  NUM2  NUM3

   10  1.490 12.539

------------------------

123456789012345678901234 <-- DO NOT output this area. It is here to help you align things.


1
Expert's answer
2021-02-01T08:50:42-0500
#include <iostream>
#include <iomanip>


using namespace std;


int main()
{
	int NUM1 = 10;
	float NUM2 = 1.49f;
	float NUM3 = 12.538767f;


	cout << setprecision(3) << fixed;


	cout << "NUM1" << "\tNUM2" << "\tNUM3\n";
	cout << NUM1 << "\t" << NUM2 << "\t" << NUM3 << endl;


	return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog