Friday, 27 April 2012

Program Of Set Precision Manipulator In C++

#include<iostream.h>
#include<conio.h>
#include<math.h>
#include<iomanip.h>
#include<stdio.h>
main()
{
clrscr();
float n;
cout<<"Enter Value of n=";
cin>>n;
cout<<"\n--------------------------------------------------------------\n";
cout<<setw(5)<<"num"<<setw(16)<<"SQR(HEX Form)"<<setw(12)<<"sqrt";
cout<<setw(15)<<"SQR-SCR";
cout<<"\n---------------------------------------------------------------\n";
cout.setf(ios::showpoint);
for(int j=1;j<=n;j++)
{
cout<<setw(5)<<j
<<setw(8)<<setiosflags(ios::hex)
<<setw(8)<<j*j
<<setw(20)<<setprecision(2)<<sqrt((double)j)
<<setw(20)<<setprecision(3)<<setiosflags(ios::scientific)
<<sqrt((double)j);
cout<<resetiosflags(ios::hex);
cout<<resetiosflags(ios::scientific)<<"\n" ;
}
getch();
}


No comments:

Post a Comment