The setw Manipulator in C++ - Example program
Write a program that uses "setw" manipulator to print output on the computer screen. See sample output given below:
This program can be solve by using "setw" manipulator (It stands for set width. it is used to set width of output). For using this manipulator "<iomanip.h>" header file must be used in preprocessor section.
See program output:
Program CODE:
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
main(){
clrscr();
cout<<setw(5)<<62<<setw(5)<<8<<endl;
cout<<setw(5)<<100<<setw(5)<<77<<endl;
cout<<setw(5)<<5<<setw(5)<<162<<endl;
}
#include<conio.h>
#include<iomanip.h>
main(){
clrscr();
cout<<setw(5)<<62<<setw(5)<<8<<endl;
cout<<setw(5)<<100<<setw(5)<<77<<endl;
cout<<setw(5)<<5<<setw(5)<<162<<endl;
}
0 comments:
Post a Comment