answersLogoWhite

0

#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

14y ago

Still curious? Ask our experts.

Chat with our AI personalities

CoachCoach
Success isn't just about winning—it's about vision, patience, and playing the long game.
Chat with Coach
ReneRene
Change my mind. I dare you.
Chat with Rene
ViviVivi
Your ride-or-die bestie who's seen you through every high and low.
Chat with Vivi
More answers

#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;

}

User Avatar

Wiki User

16y ago
User Avatar

#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

User Avatar

Wiki User

15y ago
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