answersLogoWhite

0


Best Answer

#include<stdio.h>

#include<conio.h>

void main()

{

int i,j,k=0,l;

clrscr();

for(i=1;i<=5;i++)

{

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

{

k++;

printf("%d ",k%2);

}

for(l=i;l<=4;l++)

{

k++;

}

printf("\n");

}

getch();

}

User Avatar

Wiki User

13y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

15y ago

#include <iostream>

using namespace std;

void printTriangle(int iterations)

{

for(int i = 0; i < iterations; i++)

{

cout << "1";

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

cout << "01";

cout << endl;

}

}

int main()

{

printTriangle(4);

return 0;

}

This answer is:
User Avatar

User Avatar

Wiki User

15y ago

#include
#include
void main()
{
int j,n,i=1;
clrscr();
printf("Enter How Many Times:");
scanf("%d",&n);
for(j=1;j<=n;j++)
{
printf("%d",i);
if(i==1)
i=0;
else
i=1;
}
getch();
}

output:
Enter How Many Times:10
1010101010

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a C program to print the pattern 1 01 101 0101 10101?
Write your answer...
Submit
Still have questions?
magnify glass
imp