Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

31,166 questions

40,722 answers

573 users

How to print floating-point value using fixed-point notation in C++

1 Answer

0 votes
#include <iostream>

using std::cout;
using std::endl;

int main()
{
	double f1 = 3.14;
	double f2 = 782.0;
	double f3 = 123456.0;

	cout.setf(std::ios::fixed, std::ios::floatfield);
	cout << "f1: " << f1 << "  f2: " << f2 << "  f3: " << f3 << endl;

	return 0;
}

/*
run:

f1: 3.140000  f2: 782.000000  f3: 123456.000000

*/

 





answered May 21, 2018 by avibootz
...