Menu
Jan 10, 2018 iomanip is a input/output header file in C. It is a function which is used to manipulate i/o statements. There are two types of manipulators. 1)The one which works with input stream. 2)The one which works with output stream. Iomanip setpricision function in C with Examples The setprecision method of iomaip library in C is used to set the ios library floating point precision based. Jun 27, 2010 By naming your sourcefile with the.c extension you force the compiler to perform C compilation and Dev-C ti use C compilation settings. Dev-C's C compilation settings do not include the C backward compatibility directory (for obvious reasons), and, and even if it did the iostream.h header file would not compile as C code.
- The C Standard Library
- The C++ Standard Library
- The C++ STL Library
- C++ Programming Resources
- Selected Reading
Description
The C++ function std::setprecision behaves as if member precision were called with n as argument on the stream on which it is inserted/extracted as a manipulator (it can be inserted/extracted on input streams or output streams).
It is used to sets the decimal precision to be used to format floating-point values on output operations.
Declaration
Following is the declaration for std::setprecision function.
C++ Iomanip Commands
Parameters
![Dev Dev](/uploads/1/2/6/0/126086162/816433735.jpg)
n − New value for the decimal precision.
Return Value
Iomanip In C++
It returns unspecified. This function should only be used as a stream manipulator.
Exceptions
Basic guarantee − if an exception is thrown, the stream is in a valid state.
Data races
The stream object on which it is inserted/extracted is modified. Concurrent access to the same stream object may introduce data races.
Example
In below example explains about setprecision function.
Let us compile and run the above program, this will produce the following result −
![Dev c++ for windows 10 Dev c++ for windows 10](/uploads/1/2/6/0/126086162/839728482.png)
iomanip.htm