//%f // placeholder for a float value
//%.2f //as a placeholder, your float will be written rounded to 2 decimal places
// if you require a truncated representation, consider
// integer division or std::trunc() from <math.h> or <cmath>
// example string:
printf("Your total is $%.2f", 30.999);
//output:
//Your total is $31.00
Code Example |
---|
Cpp :: vector in c++ |
Cpp :: why convert char* to string c++ |
Cpp :: how to format decimal palces in c++ |
Cpp :: Subarray with given sum in c++ |
Cpp :: double array size c++ |
Cpp :: initialize a vector to 0 |
Cpp :: length of a string c++ |
Cpp :: number of nodes of bst cpp |
Cpp :: string comparison c++ |
Cpp :: data types in c++ |
Cpp :: how to grab each character from a string |
Cpp :: walk filesystem in c++ |
Cpp :: rock paper scissor c++ |
Cpp :: converting decimal to binary in cpp |
Cpp :: Syntax for C++ Operator Overloading |
Cpp :: Pseudocode of Dijkstra’s Algorithm in C++ |
Cpp :: how to write int variable c++ |
Cpp :: C++ Arrays and Loops |
Cpp :: Euler constant |
Cpp :: cout stack in c++ |
Cpp :: C++ rename function |
Cpp :: remove whitespace in cpp |
Cpp :: #define in cpp |
Cpp :: stl map remove item |
Cpp :: c++ switch case |
Cpp :: cpp substring |
Cpp :: virtual function in c++ |
Cpp :: inverted triangle c++ |
Cpp :: C++ CHEAT SHEAT |
Cpp :: Madiar loh |