Programming Hub C,C++,C#,Asp.Net,Ado.Net,Java,  HTML,SQL.

This Blog Post Only Education Purpose For All Education Related Blogs and Articles Post Here.Download Free Software and Study Materials Mores..

Tuesday 10 April 2018

C++ Precision function Program with Output

C++ Precision Program

Sets the decimal precision to be used to format floating-point values on output operations. 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).

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
cout<<"pre set to 3 digit\n\n";
cout.precision(3);
cout.width(10);
cout<<"value";
cout.width(15);
cout<<"sqrt of value"<<"\n";
for(int n=1;n<=5;n++)
{
cout.width(8);
cout<<n;
cout.width(13);
cout<<sqrt(n)<<"\n";
}
cout<<"\n set precision set of 5 digit \n\n";
cout.precision(5);
cout<<"sqrt(10)="<<sqrt(10)<<"\n\n";
cout.precision(0);
cout<<"sqrt(10)="<<sqrt(10)<<"(default setting\n";
return 0;
}

--------------------------------------------------------------------------------------------------------------------------

Output With Example

C++ Precision Program

No comments:

Post a Comment

Please Comment Your Valuable Feedback....

You Might Also Like

Developing Data-Centric Windows Applications using Java

Developing Data-Centric Windows Applications using Java Introduction The Core Java Programming and JDBC course provides an introd...

Unlimited Reseller Hosting