Tuesday, May 15, 2018

Using SETW in C++

In this article I would like to share with you a simple program to show how to use setw or set width in C++.

I am currently accepting programming work, it project, school programming projects , thesis and capstone projects, IT consulting work and web development work kindly contact me in the following email address for further details.  If you want to advertise in my website kindly contact me also in my email address also. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.



Program Listing

#include<iostream>
#include<cstdlib>
#include<iomanip>

using namespace std;

int main() 
{
    cout<<"Apple"<<endl;
    cout<<"Banana"<<endl;
    cout<<"123.456"<<endl;

    cout<<endl;

    cout<<setw(10);
    cout<<"Apple"<<endl;
cout<<setw(10);
cout<<"Orange"<<endl;
 
    
    cout<<setw(10)<<"Banana"<<endl;
    cout<<setw(10)<<"123.456"<<endl;

    cout<<endl;
    
    //no setw, so no formatting
    cout<<"Apple"<<endl;
    cout<<"Orange"<<endl;
      

    system("pause");
    return 0;
}

No comments:

Post a Comment