fork download
  1. #include<stdio.h>
  2. void main(){
  3. int i,j,k,lines,l,m;
  4. int arr[4]={1,0,0,1};
  5. printf("Enter lines: ");
  6. scanf("%d",&lines);
  7. printf("\n\n");
  8. for(i=1;i<lines;i++){
  9. if(i%2==0){
  10. m=k=2;
  11. l=4;
  12. }
  13. else{
  14. m=k=0;
  15. l=2;
  16. }
  17. for(j=0;j<i;j++){
  18. printf("%d ",arr[k]);
  19. k++;
  20. if(k==l){
  21. k=m;
  22. }
  23. }
  24. printf("\n");
  25. }
  26. }
stdin
10
compilation info
prog.c:2: warning: return type of ‘main’ is not ‘int’
prog.c: In function ‘main’:
prog.c:6: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result
stdout
Enter lines: 

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  
0  1  0  1  0  1  0  1  
1  0  1  0  1  0  1  0  1