This is the code which gives my desired output using spaces, but I have to perform the task using setw which isn't working as I want(2nd code attached). Help please!
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
cout << " _________________________________________________________" <<endl ;
cout << " / \\ " <<endl;
cout << " / \\ " <<endl;
cout << " / \\ " <<endl;
cout << " / \\ " <<endl;
cout << " / \\ " <<endl;
cout << " / \\ " <<endl;
return 0;
}
Desired code which doesn't works:
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
cout << setw(15) << "_________________________________________________________" <<endl ;
cout << setw(14)<< "/ \\ " <<endl;
cout << setw(13)<< "/ \\ " <<endl;
cout << setw(12)<< "/ \\ " <<endl;
cout << setw(11)<<"/ \\ " <<endl;
cout << setw(10)<<"/ \\ " <<endl;
cout << setw(9)<<"/ \\ " <<endl;
return 0;
}
The desired output:
_________________________________________________________
/ \
/ \
/ \
/ \
/ \
/ \