C++ For Loop_1.13

#include <iostream>
using namespace std;
int main (void)
{
    int i,j;
    freopen("out.txt","w",stdout);
    for(i=1;i<=6;i++)
    {
       for(j=1;j<=i;j++)
       if(i%2==1)
       {
                 if(j%2==1)
                 cout<<"*";
                 else
                 cout<<"#";
       }
       else
       {
                 if(j%2==1)
                 cout<<"#";
                 else
                 cout<<"*";
       }
       cout<<"\n";
    }
}


The Output is Given Below:
*
#*
*#*
#*#*
*#*#*
#*#*#*

0 comments:

Post a Comment