Answer to Question #292463 in C++ for Moo Moustafa

Question #292463

Design, write and compile a C++ program to display the following output using setw(), setprecision(), setiosflags():

 

Radians

  Degrees

1

57.2958

10

572.9580

20

1145.9200

30

1718.87000

40

2291.83000

 

 

 

 

 

 

 

(b) What is the minimum number of cout statements that could be used to print the above output?

(c) Explain your choice of coding style with your chosen number of cout statements. 

 


1
Expert's answer
2022-01-31T11:28:26-0500
#include<iostream>
#include<iomanip>

using namespace std;

int main()
{
	cout<<"Radians\n Degrees\n"<<1<<endl<<setprecision(10)
	<<57.2958<<endl<<10<<endl<<fixed<<setprecision(4)
	<<572.958<<endl<<20<<endl<<1145.92<<endl<<30<<endl
	<<setprecision(5)<<1718.87<<endl<<40<<endl
	<<2291.83;
//b) We can use only 1 cout statement
/*c) I think if we use min amount of cout statements, we have a bit better performance, because of less amount of operations*/

}

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