Search C Program

Number Pattern - 15

1
01
101
0101

#include <stdio.h>
int main()
{
  int i, j;
  for(i=1;i<=4;i++)
  {
    for(j=i;j>=1;j--)
    {
      printf("%d",j%2);
    }
    printf("\n");
  }
  return 0;
}



Related Links:
- More Number Pattern Programs
- Star Pattern Programs in C
- Alphabet Pattern Programs in C
- Series Programs in C


14 comments:

  1. I really appreciate your approach

    ReplyDelete
  2. Thank U!!Great job....got stuck here for 10days

    ReplyDelete
  3. this helped me a lot. thank you.

    ReplyDelete
  4. 1
    01
    101
    0101

    #include
    int main()
    {
    int i, j;
    for(i=1;i<=4;i++)
    {
    for(j=i;j>=1;j--)
    {
    printf("%d",j%2);
    }
    printf("\n");
    }
    return 0;
    }

    this program use in (j--) why explain me please

    ReplyDelete
    Replies
    1. Because he wants to print no. Of digits respective to count of rows only

      Delete
  5. Check this out (not tested)
    For(i=0;i<4;i++)
    {
    For(j=0;j<i;j++)
    {
    If(i+j%2=0)
    {
    Printf("1");
    }
    Else
    {
    Printf("0");
    }
    }
    Printf("\n");
    }

    ReplyDelete
    Replies
    1. this programe is wrong .......

      Delete
  6. #include

    int main()
    {
    int r,i,j;

    printf("Enter the number of rows : ");
    scanf("%d",&r);

    for(i=1;i<=r;i++)
    {
    for(j=i;j>=1;j--)
    {
    printf("%d",j%2);
    }
    printf("\n");
    }

    return 0;
    }

    ReplyDelete