Write the program that prints following on the screen using setw manipulator.
* * * * *
* * * *
* * *
* *
*
with for loop u must try this code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
#include<iostrea
#include<conio>
using nammespace std;
int main()
{
for(int i=1;i<=5;i++)
{
for(int j=6-i;j>=1;j--)
{ cout<<"*"; }
cout<<endl;
}
return 0;
}
|
Last edited on
Fatimah jinnah university assignment.. first semester. I already made all assignment for my kazan there. u Want? contact me.
What about using cout.fill()
or setfill()
in conjunction with setw()
?
That way you have one line initialise, two lines: for loop, and one line tidy up.
Total four lines (plus usual overheads for #include, main() etc.).
Last edited on