The output must be
1
01
101
0101
10101
If someone could point me in the right direction...
I tried this but the result goes wrong at the third line and fourth line
Code:#include<stdio.h> #include<conio.h> void main() { int i,j,num=1,ctr=1; clrscr(); for(i=1;i<=5;i++) { for(j=1;j<=i;j++) { if(ctr%2!=0) { printf("1"); } else { printf("0"); } ctr++; } printf("\n"); } getch(); }