output format

how do i decrease the digits of a number or round it down to a specific number of digits?

for example....

1
2
3
int n;
cin >> n;
cout << n << endl;


this will output whatever int is entered but what if i want the value to be no more than 7 digits how would i do this?
Just a tip, next time use google before posting, saves you time.

http://www.cplusplus.com/reference/iomanip/setprecision/
closed account (48T7M4Gy)
int is entered but what if i want the value to be no more than 7 digits

I'm sure you meant a float or double and not an integer because integers are already well-rounded and to limit an integer to less than 7 digits means you limit the integer to an integer less than 10,000,000
Topic archived. No new replies allowed.