How to use function for cout in C++

1 Answer

0 votes
#include <iostream>

using std::cout;
using std::endl;
using std::ostream;
using std::ios;

ostream &scientific(ostream &stream)
{
	stream.setf(ios::scientific | ios::uppercase);

	return stream;
}

int main()
{
	double d = 321.875;

	cout << scientific << d << endl;

	return 0;
}



/*
run:

3.218750E+02

*/

 



answered Apr 10, 2018 by avibootz

Related questions

1 answer 167 views
167 views asked Apr 9, 2018 by avibootz
2 answers 115 views
115 views asked Feb 21, 2022 by avibootz
2 answers 242 views
1 answer 212 views
1 answer 181 views
1 answer 212 views
...