C++ Program to Demonstrate setprecision Manipulator
Code:
Sample Output:
Comment bellow for your Query and Feedback
Code:
/*C++ Program to Demonstrate setprecision Manipulator*/
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
void main(void)
{
float a=5,b=3;
clrscr();
float c=a/b;
cout << setprecision(1) <<" c = " << c << endl;
cout << setprecision(2) <<" c = " << c << endl;
cout << setprecision(3) <<" c = " << c <<endl;
cout << setprecision(4) <<" c = " << c <<endl;
cout << setprecision(5) <<" c = " << c <<endl;
getch();
}
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
void main(void)
{
float a=5,b=3;
clrscr();
float c=a/b;
cout << setprecision(1) <<" c = " << c << endl;
cout << setprecision(2) <<" c = " << c << endl;
cout << setprecision(3) <<" c = " << c <<endl;
cout << setprecision(4) <<" c = " << c <<endl;
cout << setprecision(5) <<" c = " << c <<endl;
getch();
}
Sample Output:
Comment bellow for your Query and Feedback
0 comments:
Confused? Feel free to ask
Post a Comment