1
10
101
1010
10101
please help me friends.
write the program to print the pattern
Answers
Answered by
2
Answer:
Write the program to print the given pattern.
1
10
101
1010
10101
Explanation:
#include<stdio.h>
int main()
{
int i,j,k;
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",j%2);
}
printf("\n");
}
return 0;
}
Output:-
1
1 0
1 0 1
1 0 1 0
1 0 1 0 1
Answered by
1
Following are the program in c language that is mention below
Explanation:
#include <stdio.h> // header file
int main() // main function
{
for(int i1=1;i1<=5;i1++) // iterating the loop
{
for(int j1=1;j1<=i1;j1++) // iterating the loop
{
if(j1%2==0) // check the condition
printf("0");
else
printf("1");
}
printf("\n");
}
return 0;
}
Output:
Following are the attachment of output that is given below
Following are the description of code
- To print the given pattern we have used the two for loop one is outer loop and one is inner loop .
- we start the loop from 1 and executed the value of 5 the i1 variable indicated the row and j1 indicated the column .
- the if(j1%2==0) check the condition of column and print them according .
Learn More :
- brainly.in/question/16250695
Attachments:
Similar questions