CrazyEngineers
  • C programming: Print this pattern 1 01 101 ...

    Updated: Oct 27, 2024
    Views: 1.6K
    plz help urgently to print patern
    1
    01
    101
    0101
    by using for loops in C .... .......................
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Kaustubh Katdare

    AdministratorJan 10, 2013

    Umm, did you attempt the problem on your own? How about sharing what you've tried so far so that CEans here can help you correct it?
    Are you sure? This action cannot be undone.
    Cancel
  • Jeffrey Arulraj

    MemberJan 14, 2013

    Here is a logic in even digits of control variable print 0 and in odd value of control variable print 1

    PS: Initialise control variable to 0
    Are you sure? This action cannot be undone.
    Cancel
  • rahul69

    MemberJan 14, 2013

    Here is another logic: keep concatenating a string with '0' and '1' alternatively and keep on printing the reverse of string 😎 .
    PS: Initialize string to '1'.
    Are you sure? This action cannot be undone.
    Cancel
  • Nikhil Lokhande

    MemberJan 14, 2013

    Try this one

    for(i=0;i<n;i++)
    for(j=0;j<=i;j++)
    if(((i-j)%2)==0)
    a[j]=1;
    else
    a[j]=0;
    Are you sure? This action cannot be undone.
    Cancel
  • Anoop Kumar

    MemberJan 14, 2013

    here is Algo

    Outer_loop (int i=1; i<NUMBER_OF_LINES ; i++)
    Inner_loop (j=i; j>0 ; j--)
    print (j%2);
    end Inner_loop
    print (New_line);
    end Outer_loop;

    Are you sure? This action cannot be undone.
    Cancel
  • rahul69

    MemberJan 14, 2013

    ianoop
    here is Algo

    Outer_loop (int i=1; i<NUMBER_OF_LINES ; i++)
    Inner_loop (j=i; j>0 ; j--)
    print (j%2);
    end Inner_loop
    print (New_line);
    end Outer_loop;

    Nice logic ! but I think it should be i< = NUMBER_OF_LINES instead of i<NUMBER_OF_LINES
    Are you sure? This action cannot be undone.
    Cancel
  • Anoop Kumar

    MemberJan 14, 2013

    rahul69
    Nice logic ! but I think it should be i< = NUMBER_OF_LINES instead of i<NUMBER_OF_LINES
    Yes.👍
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register