Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created January 18, 2021 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amankharwal/02216217994578b1d483e4964f3649a5 to your computer and use it in GitHub Desktop.
Save amankharwal/02216217994578b1d483e4964f3649a5 to your computer and use it in GitHub Desktop.
#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