Computer Science, asked by raghavendra98, 1 year ago

1,10,101,1010,10101 write a progam on this

Answers

Answered by darshanadash24pd6kdp
0
OUTPUT:- 

1
01
010
1010
10101



#include<stdio.h>
#include<conio.h>
void main()

{
    int i,j,k=1;
    for(i=1;i<=5;i++)
    {
        for(j=1;j<=i;j++)
        {
            if(k%2==0)
            {
                printf("0");
            }
            else
            {
                printf("1");
            }
            k++;
        }
        printf("\n");
    }
    getch();
}
Answered by Ajay1291
0
Generate the following pattern.

1
10
101
1010
10101


#include<stdio.h>

void main()

{

int i, j, n,count=1;

printf("Enter the number = ");

scanf("%d",&n);

for(i=0;i<n;i++)

{

for(j=0;j<i;j++)

{

printf("1");

if(i>1&&count<i)

{

printf("0");

count++;

}

}

printf("\n");

count=1;

}

getch();

Similar questions