Write a loop for following pattern

Report
Posts
4
Registration date
Monday December 21, 2020
Status
Member
Last seen
December 22, 2020
-
Posts
4
Registration date
Monday December 21, 2020
Status
Member
Last seen
December 22, 2020
-
1 11 111 1111 1111 11111 11111

2 replies

Posts
1112
Registration date
Wednesday November 4, 2020
Status
Administrator
Last seen
July 30, 2021
692
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
Posts
4
Registration date
Monday December 21, 2020
Status
Member
Last seen
December 22, 2020

No it's not working
Posts
4
Registration date
Monday December 21, 2020
Status
Member
Last seen
December 22, 2020

#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);
}
}
}
Posts
4
Registration date
Monday December 21, 2020
Status
Member
Last seen
December 22, 2020

This is the code for the following outputs.

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!