Follow This Blog For more... 😊

Program to print 0-1 Pattern using C++. (Slightly different from the first 0-1 Pattern)

Program to print 0-1 Pattern using C++. (Slightly different from the first 0-1 Pattern) 

CODE:


        #include<iostream>
        using namespace std;

        main()
        {
            int i,j,n,c;
           
            cout<<"Enter the number:";cin>>n;
           
            for(i=1;i<=n;i++)
            {
                c=i;
                for(j=1;j<=i;j++)
                {
                    cout<<c%2<<" ";
                    c++;
                }
                cout<<endl;
            }
        }

Output:




Comments

Popular Posts