Write a Program to Print the Following Pattern Using Nested Loops:
1
01
101
0101
10101
It is Necessary to Use Nested Loops / Multiple Loops
Answers
Answered by
4
Answer:
*
Program to print following pattern-
1
01
101
0101
10101
*/
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,n;
clrscr();
printf("\n Enter the value of n:");
scanf("%d",&n);
for(i=0;i<=n;i++)
{
for(j=1;j<i;j++)
{
if((i+j)%2==0)
{
printf("\t 0");
}
else
{
printf("\t 1");
}
}
printf("\n");
}
getch();
}
Output:
Answered by
3
Answer:
Program to print following pattern-
1
01
101
0101
10101
*/#include<stdio.h> #include<conio.h> void main()
{ int i,j,n; clrscr(); printf("\n Enter the value of n:"); scanf("%d",&n); for(i=0;i<=n;i++)
{ for(j=1;j<i;j++){ if((i+j)%2==0) { printf("\t 0"); }
else
{ printf("\t 1"); } } printf("\n"); } getch();
Explanation:
please mark me as brainliest
Similar questions