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

plz help urgently to print patern
1
01
101
0101
by using for loops in C .... .......................

Replies

  • Kaustubh Katdare
    Kaustubh Katdare
    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?
  • Jeffrey Arulraj
    Jeffrey Arulraj
    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
  • rahul69
    rahul69
    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'.
  • Nikhil Lokhande
    Nikhil Lokhande
    Try this one

    for(i=0;i for(j=0;j<=i;j++)
    if(((i-j)%2)==0)
    a[j]=1;
    else
    a[j]=0;
  • Anoop Kumar
    Anoop Kumar
    here is Algo

    Outer_loop (int i=1; i
    Inner_loop (j=i; j>0 ; j--)โ€‹
    print (j%2);โ€‹
    end Inner_loopโ€‹
    print (New_line);โ€‹
    end Outer_loop;

    โ€‹
  • rahul69
    rahul69
    ianoop
    here is Algo

    Outer_loop (int i=1; 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
  • Anoop Kumar
    Anoop Kumar
    rahul69
    Nice logic ! but I think it should be i< = NUMBER_OF_LINES instead of iYes.๐Ÿ‘

You are reading an archived discussion.

Related Posts

I've been experimenting with the number of posts CEans would like to have on the site - 10 or 20? You decide. Currently we have 10 posts per page, so...
Source Internet: Client side scripting is a script, (ex. Javascript, VB script), that is executed by the browser (i.e. Firefox, Internet Explorer, Safari, Opera, etc.) that resides at the user...
hi........can somebody explain how a bluetooth controlled helicopter works????
Looks as though a breakthrough in areal transport is imminent. Aeros have unveiled a working prototype of a lighter than air craft that bodes well to introduce a leisurely, luxurious...
Genome mapping is about to invade the cyberspace. Malware is the bane of the Internet. Currently one tries to develop anti malware cures after one surfaces. Invincea labs in Fairfax,...