Write nested for c++ loops to produce the following output.
×××× / / / / / / / / ××××
××× / / / / / / \ \ ×××
×× / / / / \ \ \ \ ××
× / / \ \ \ \ \ \ ×
\ \ \ \ \ \ \ \
#include<iostream>
using namespace std;
int main()
{
const int N=5;
for(int row=0;row<N;row++)
{
for(int i=4-row;i>0;i--)
{
cout<<"x";
}
for(int i=8-row*2;i>0;i--)
{
cout<<"/";
}
for(int i=row*2;i>0;i--)
{
cout<<"\\";
}
for(int i=4-row;i>0;i--)
{
cout<<"x";
}
cout<<endl;
}
}
Comments
Leave a comment