fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int n;
  5. printf("Enter the number: \n");
  6. scanf("%d",&n);
  7. int a;
  8. for(int i=1;i<=n;i++){
  9. if(i%2==0) a=0;
  10. else a=1;
  11. for(int j=1;j<=i;j++){
  12. printf(" %d ",a);
  13. if(a==0) a=1;
  14. else a=0;
  15.  
  16.  
  17. }
  18. printf("\n");
  19.  
  20. }
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0.01s 5288KB
stdin
7
stdout
Enter the number: 
 1 
 0  1 
 1  0  1 
 0  1  0  1 
 1  0  1  0  1 
 0  1  0  1  0  1 
 1  0  1  0  1  0  1