Pattern 24
// Pyramid
#include<stdio.h>
int main()
{
int i,j,s,k;
for(i=5;i>=1;i--) // // for loop that prints spaces.
{
for(s=5;s>=i;s--)
{
printf(" ");
}
for(j=i;j>=1;j--) // for loop that prints 1.
{
printf("%d ",j%2);
}
for(k=2;k<=i;k++) // for loop that prints 0.
{
printf("%d ",k%2);
}
printf("\n");
}
return 0;
}
#include<stdio.h>
int main()
{
int i,j,s,k;
for(i=5;i>=1;i--) // // for loop that prints spaces.
{
for(s=5;s>=i;s--)
{
printf(" ");
}
for(j=i;j>=1;j--) // for loop that prints 1.
{
printf("%d ",j%2);
}
for(k=2;k<=i;k++) // for loop that prints 0.
{
printf("%d ",k%2);
}
printf("\n");
}
return 0;
}
Comments
Post a Comment