Program : Use Setw() Function
The setw() function is used to set the field width of the output data. For using setw() we have to use iomanip header file. In bracket that of setw we have to write integer value according to output to be shown.
Let see following program to better understand :-
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
int main()
{
cout << "HELLO" << setw(7) << "World" ;
getch();
return 0;
}
The setw() function is used to set the field width of the output data. For using setw() we have to use iomanip header file. In bracket that of setw we have to write integer value according to output to be shown.
Let see following program to better understand :-
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
int main()
{
cout << "HELLO" << setw(7) << "World" ;
/* cout for display data on screen it Shows HELLO World, After Hello, their is one space as i gave and World is of 5 character and we set width of 7 it means we get 7 columns and we have to fill with that data here World so Output is HELLO<space><space>World. Their is two space after HELLO because we give width = 7 and 5 are filled and two are filled with space & it start from Right. */
getch();
return 0;
}
thank you!
ReplyDeletefantastic and excellent programming, and the way you explained the setw() is so excellent;
ReplyDeletethanks
Thanks very much Admin !
ReplyDeletethanks dude
ReplyDeleteexcellent way of teaching
ReplyDeletei tried many websites but could not understand anything.
This is the BEST place to learn programming
Excellent teaching way .Looking forward to know more about this type of solution .than you
ReplyDeletethanks
ReplyDeletelol its easy to learn here, thanks for it,.!
ReplyDeletebest site .. (y)
ReplyDeletethanks dude
ReplyDeleteThank you so much... Love the way you explain.. keep up the good work
ReplyDelete