Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created Jan 18, 2021
Embed
What would you like to do?
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
double x1 = 0.123456, x2 = 23.987, x3 = 123.456;
//a
cout<<left<<setw(15)<<x1<<endl;
//b
cout<<fixed<<setprecision(2)<<right<<setw(12)<<x2<<endl;
//c
cout<<scientific<<setprecision(4)<<x3<<endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment