Topic:
'setw' Manipulator in C++ Manipulators
Problem:
Write a program that explains the use of setw manipulator.
Solution:
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
int main ()
{
cout<<endl<<endl<<endl;
int n=458;
char str[]="hello world";
cout<<setw(2)<<n<<endl<<setw(16)<<str<<endl;
getch();
}
#include<conio.h>
#include<iomanip.h>
int main ()
{
cout<<endl<<endl<<endl;
int n=458;
char str[]="hello world";
cout<<setw(2)<<n<<endl<<setw(16)<<str<<endl;
getch();
}
Output:
Let me know in the comment section if you have any question.
Previous Post:
Next Post: