Contact Learn C
Copy

Program 254:Print Binary Pyramid

Program 254:Print Binary Pyramid

#include<stdio.h> 
main()
{
    int i,j,k,rows,count,temp=1,totalNumbers=1;
    printf("Enter number of rows:\n");
    scanf("%d",&rows);
    count=rows-1;
    
    for(i=1;i<=rows;i++)
    {
        for(j=1;j<=count;j++)
        {
            printf(" ");
            
        }
        for(k=1;k<=temp;k++)
        {
           printf("%d",totalNumbers%2);
            totalNumbers++;
        }
        count--;
        temp+=2;
    
        printf("\n");
    }    
}
Explanation:

//Coming Soon

Output:
Binary Pyramid Ouput






Donate

Download App and Learn when ever you want

Get it on PlayStore
Get it on Amazon App Store
Get it on Aptoide