Question

In: Computer Science

C++ give some examples of where you could use the stream manipulators to format output.

C++ give some examples of where you could use the stream manipulators to format output.

Solutions

Expert Solution

//examples.cpp
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
   //endl
   //this flushes the output stream and also acts as new line
  
   cout<<"- - - - - - - - endl - - - - - - - -\n\n";
   cout<<"Following Line appers in new Line:"<<endl<<"Hi Iam printing in new line"<<endl;
   cout<<"\n\n- - - - - - - - - - - - - - - -\n\n";
  
   //setw(n)
   //setw() manipulator changes the width of the next input/output field.
   //it sets the width parameter of the stream out or in to exactly n.
   //it prints the n number of white spaces
   cout<<"\n\n- - - - - - setw(n) - - - - - - - - -\n\n";
   cout <<"without setw(n): "<< 120 << " " << 12<<endl;
   cout <<"With setw(15) : "<< 120 << setw(15) << 12<<endl;
   cout<<"\n\n- - - - - - - - - - - - - - - -\n\n";
  
  
   //setprecision(n)
   //sets the floating point precision to be displayed
  
   cout<<"\n\n- - - - - - setprecision(n) - - - - - - - - - -\n\n";double pi = 3.141592653589793239;
   cout << "default precision (6) of PI : " << pi << '\n';
   cout << "std::setprecision(10) of PI: " << setprecision(10) << pi << '\n';
   cout<<"\n\n- - - - - - - - - - - - - - - -\n\n";
  
   //showpoint/noshowpoint
   //used to show a decimal point or not
   cout<<"\n\n- - - - - - showpoint/noshowpoint - - - - - - - - - -\n\n";
  
   cout<<"No ShowPoint of 11.0 : "<<noshowpoint<<11.0<<endl;
   cout<<"ShowPoint of 11.0 : "<<showpoint<<11.0<<endl;
   cout<<"\n\n- - - - - - - - - - - - - - - -\n\n";
   return 0;
}


Related Solutions

a. Give some examples where a bank would use securitized instruments. b. Describe an example where...
a. Give some examples where a bank would use securitized instruments. b. Describe an example where a bank could control their risk exposure to a counterparty or asset class using Securitized instruments such as CDS or MBS. c. Why would a counterparty purchase these securities offered by the bank?
Could you give some sample Java code of creating a program where users are prompt to...
Could you give some sample Java code of creating a program where users are prompt to determine how many exams they have taken then it is prompt that they have to enter their test scores and gives the sum of all their test scores? You should have to use looping
In a paragraph share an area where you feel you could use some encouragement in your...
In a paragraph share an area where you feel you could use some encouragement in your life.
Give examples of studies where in the null hypothesis would be the preferred use, and examples...
Give examples of studies where in the null hypothesis would be the preferred use, and examples of where the alternative hypothesis would be more useful.
Describe examples of situations where you could appropriately use the following. Explain why the procedure is...
Describe examples of situations where you could appropriately use the following. Explain why the procedure is the correct one to use and identify the statistic to be used and explain why that is the correct choice. a. Confidence interval for a proportion. b. Confidence interval for a mean, unknown σ. c. Confidence interval for a mean, σ known. Describe procedure for following and provide an example of the calculations: d. Margin of error calculation for 95% confidence level. e. Sample...
Describe examples of situations where you could appropriately use the following. Explain why the procedure is...
Describe examples of situations where you could appropriately use the following. Explain why the procedure is the correct one to use and identify the statistic to be used and explain why that is the correct choice. (1 point each) Confidence interval for a proportion. Confidence interval for a mean, unknown σ. Confidence interval for a mean, σ known. Describe procedure for following and provide an example of the calculations: Margin of error calculation for 95% confidence level. Sample size determination...
What could be some examples a clothing business could use forecasting in the following categories: -Technological...
What could be some examples a clothing business could use forecasting in the following categories: -Technological forecasts-rates of technological change -economic forecasts-predicting changes of business cycles -business forecasts-predicting demand Thank you in advance!
What is a stepper motor and give some examples of where a stepper motor may be...
What is a stepper motor and give some examples of where a stepper motor may be utilized.
1a. Give 6 examples where Energy is Conserved in an event. 1b. Give 6 examples where...
1a. Give 6 examples where Energy is Conserved in an event. 1b. Give 6 examples where Energy is NOT Conserved in an event. 1c. Give 2 examples of an event where Momentum is NOT Conserved.
Give some examples of colonial animals where the individual units within a colony are specialized for...
Give some examples of colonial animals where the individual units within a colony are specialized for different functions. What are the functions? What colonial animals do not show specialization within a colony, i.e., all the units are instead functionally equivalent. Be sure to consider this question at the level of phyla and do discuss ALL of the colonial phyla that we have discussed in this course. Note if all the members of the phylum share the features you mention or...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT