Write a C++ code for the following pattern display using ios classes. The precision is set according to the value of variable x. (use setprecision(), setwidth(), setfill() ios flags and functions).
#include <iostream>
#include <conio.h>
#include <iomanip>
using namespace std;
//The start point of the program
int main (){
float x;
//get the number from the user
cout<<"Enter x: ";
cin>>x;
//Display result
cout.width (10);
cout.fill(' ');
cout<<fixed <<"Round number is: "<<setprecision(2)<<x<<"\n\n";
//delay
system("pause");
return 0;
}
Comments
Leave a comment