Search
 
SCRIPT & CODE EXAMPLE
 

CPP

double number print 3 digit after decimal point in c++

//use #include<iomanip>
cout<<"Result = "<<fixed<<setprecision(3)<<result;//like Result = 2.434
Comment

print float number with only four places after the decimal point in c++

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
  value = 3.15647;
  std::cout << std::fixed << std::setprecision(2);
  std::cout<<value<<std::endl;
	return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: strip space from string cpp 
Cpp :: c++ reverse integer 
Cpp :: how to read and parse a json file with rapidjson 
Cpp :: C++ switch cases 
Cpp :: http.begin arduino not working 
Cpp :: how to make a random number in c++ 
Cpp :: c++ hide show console 
Cpp :: string to int in c++ 
Cpp :: split string on character vector C++ 
Cpp :: c++ return multiple values 
Cpp :: memcpy c++ usage 
Cpp :: search a word in cpp file 
Cpp :: how to clear vector c++ 
Cpp :: vector.find() 
Cpp :: c++ vector pop_back 
Cpp :: sleep c++ 
Cpp :: cpp std list example 
Cpp :: c++ print string 
Cpp :: min element in stl c++ 
Cpp :: time_t to int 
Cpp :: how to split a string in c++ 
Cpp :: string to uint64_t c++ 
Cpp :: c++ hello world 
Cpp :: how to remove a index from a string in cpp 
Cpp :: how to append to a vector c++ 
Cpp :: min heap priority queue c++ 
Cpp :: cpp print variable value 
Cpp :: integer to char c++ 
Cpp :: if statement c++ 
Cpp :: how can we create 4 digit random number in c++ 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =