Contact Learn C
Copy Program Share Program

Program 253:Print Reverse Binary Pyramid

Program 253: Program to print Binary Reverse Pyramid

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

//Coming Soon

Output:
Print Reverse Binary Pyramid

Print Reverse Binary Pyramid







Download App and Learn when ever you want

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