Skip to content

C++ Program to Demonstrate setprecision Manipulator

C++ Program to Demonstrate setprecision Manipulator

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();
}

Sample Output:

Comment bellow for your Query and Feedback

Leave a Reply

Your email address will not be published. Required fields are marked *

error: Content is protected !!