Sunday, October 16, 2011

Pattern {Right Angles Triangle III}

#include<stdio.h>
#include<conio.h>
void main()
{
      int n, c, k, num = 1;
      clrscr();
      scanf("%d", &n);
      for ( c = 1 ; c <= n ; c++ )
      {
          for ( k = 1 ; k <= c ; k++ )
          {
              printf("%d", num);

              if ( num == 0 )
                 num = 1;
              else
                 num = 0;
          }
          printf("\n");
      }
      getch();
}

1
01
010
1010
10101

No comments:

Post a Comment