Friday, October 25, 2013

solve this pattern...

Make the program in the C to print the following pattern...

0
10
010
1010
01010

try it !!!!

2 comments:

  1. #include

    using namespace std;

    int main()
    {
    int var,n=5;

    for(int i=1;i<=n;i++)
    {

    if(i%2==0)
    {
    var=0;
    }
    else
    {
    var=1;
    }

    for(int j=1;j<=i;j++)
    {
    if(var == 0)
    {var=1;}
    else
    {var=0;}

    cout<<""<<var;
    }
    cout<<endl;
    }

    }

    ??????

    ReplyDelete