setw & setprecision understanding help

Hello there. Can anyone tell me how to count the setw and setprecision without using compiler. An explanation and way to know how to count it much appreciated. :D

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
	float x=23.5, y=67.0;
	int m=13, n=125;
	cout<<fixed<<setprecision(5)<<setw(8)<<n/x<<endl;
	cout<<setw(5)<<n/m<<endl;
   system("Pause");
   return 0;
}
Last edited on
I am afraid your question doesn't make any sense. What do you mean by count setw? What do you mean by not using the compiler?
Hello DesmondLee,

The number used in setprecision(5) is the number of places to the right of the decimal point. This is your choice.

The number used in setw(8) is also your choice depending on what you want to do. I have not thought of using a variable for "setw", but I do not see why it could not be done. Sometimes you just make it wide enough to work or count the number of characters in the longest line that will print and work from there.

Hope that helps,

Andy
@Hand Andy thanks for the reply. :) i get it now.

@TheIdeasMan maybe im not clear by what im trying to say. Anyway im clear with it now.

Last edited on
Topic archived. No new replies allowed.