Pattern7

Program to print pattern as shown in sample output.

Sample Input
5
Sample Output
1
0 1
0 1 0
1 0 1 0
1 0 1 0 1
Solution in C JAVA PYTHON
#include<stdio.h>
int main() {
  int n,num=1;
  scanf("%d",&n);
  for(int row=1;row<=n;row++){
    for(int col=1;col<=row;col++){
      printf("%d",(num++)%2);
      if(col<=row-1){
        printf(" ");
      }
    }
    if(row<=n-1){
      printf("\n");
    }
  }
}