print 10101 and 01010 series using for loop

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bsgcollege
    New Member
    • Apr 2014
    • 1

    print 10101 and 01010 series using for loop

    10101
    01010
    10101
    01010
    i want print above series using for loop.
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Can you write a for loop that cycles 4 times?

    If you look vertically you will see each columns changes from 1 to 0 or 0 to 1.

    Define four bools.

    Change the state of these bools on each cycle of the loop.

    Post again after you have a little code.

    Comment

    • techboy
      New Member
      • Apr 2014
      • 28

      #3
      I think he is need of pattern code i.e using only two for loops and which is the better approach.
      Understand the pattern as a i*j matrix such that
      when i = even print the even j values as '1' and
      when j = odd print the odd j values as '1'
      else where print '0'.

      Comment

      Working...