Write a loop for following pattern

Closed
Caption1
Posts
4
Registration date
Monday December 21, 2020
Status
Member
Last seen
December 22, 2020
- Dec 21, 2020 at 03:46 AM
Caption1
Posts
4
Registration date
Monday December 21, 2020
Status
Member
Last seen
December 22, 2020
- Dec 22, 2020 at 05:03 AM
1 11 111 1111 1111 11111 11111

2 replies

Elena Keracheva
Posts
1152
Registration date
Wednesday November 4, 2020
Status
Administrator
Last seen
October 28, 2021
899
Dec 21, 2020 at 04:29 AM
Hello,

this question wa resolved here: https://ccm.net/forum/affich-352505-c-program-to-print-1-11111-1111#answers

Let me know if that helps,
Elena
1
Caption1
Posts
4
Registration date
Monday December 21, 2020
Status
Member
Last seen
December 22, 2020

Dec 22, 2020 at 05:02 AM
No it's not working
0
Caption1
Posts
4
Registration date
Monday December 21, 2020
Status
Member
Last seen
December 22, 2020

Dec 22, 2020 at 05:03 AM
#include<stdio.h>
void main()
{
for(int q=1;q<=2;q++)
{
if(q<2)
for(int i=1;i<=3;i++)
{
for(int j=1;j<=i;j++)
printf("%d",1);
printf(" ");
}
else if(q=2)
for(int i=4;i<=5;i++)
{
int flag=0;
do{
for(int j=1;j<=i;j++)
printf("%d",1);
flag++;
printf(" ");
}while(flag<=1);
}
}
}
0
Caption1
Posts
4
Registration date
Monday December 21, 2020
Status
Member
Last seen
December 22, 2020

Dec 22, 2020 at 05:03 AM
This is the code for the following outputs.
0