Illustrates various integer width cout modifiers, setw - C++ Language Basics

C++ examples for Language Basics:Console

Description

Illustrates various integer width cout modifiers, setw

Demo Code

#include <iostream>
#include <iomanip>
using namespace std;

int main()/*from   www.  j  a  va  2s  .c o  m*/
{
   cout << 456 << 456 << 456 << "\n";   
   cout << setw(5) << 456 << setw(5) << 456 << setw(5) << 456 << "\n";          
   cout << setw(7) << 456 << setw(7) << 456 << setw(7) << 456 << " \n";        
   return 0;
}

Result


Related Tutorials