Subscribe Us

Responsive Advertisement

Advertisement

Managing Console I/O Operation OOP | | C++

 

Managing Console I/O Operation OOP | | C++




#include<bits/stdc++.h>

#include<iostream>

using namespace std;

int main()

{

   /* int c=0;

    char ch;

    cin.get(ch);

    while(ch!='\n')

    {

        c++;

        cout<<ch;

          cin.get(ch);

    }

    cout<<"\nNumber of character "<<c<<endl;



    string s;

    getline(cin,s);


    cout<<s<<endl;

    cout.width(5);//width

    int x=123;

    cout<<x;*/



   float y;

   y=10.5161;

   cout.precision(2.0);

   cout<<y<<endl;

   cout<<fixed<<setprecision(2)<<y<<endl;



   cout.width(7);

   cout<<fixed<<setprecision(2)<<y<<endl;



   cout.fill('*');

   cout.width(10);

   cout<<fixed<<setprecision(2)<<y<<endl;


  int n=10;

  cout.setf(ios::hex,ios::basefield);

  cout<<n<<endl;



   cout.setf(ios::oct,ios::basefield);

  cout<<n<<endl;


   cout.setf(ios::dec,ios::basefield);

  cout<<n<<endl;


  double m;

  m=100;

   cout.setf(ios::scientific,ios::floatfield);

  cout<<m<<endl;


    return 0;

}


Post a Comment

0 Comments