write a program for a follwing pattern:
1
1 0 1
1 0 0 0 1
.....for n terms
Answers
Answered by
0
for(int i=0; i<=n; i+=2)
{
if(i!=0)
{
for(int j=0; j<i+1; j++)
{
if(j==0 || j==i)
print("1");
else
print("0");
}
}
else
print ("1");
print("\n");
}
{
if(i!=0)
{
for(int j=0; j<i+1; j++)
{
if(j==0 || j==i)
print("1");
else
print("0");
}
}
else
print ("1");
print("\n");
}
Similar questions