print following while X is entered by user | CTechnotips

Question : Print Following while X is entered by user .

Here X=4

0001000
0011100
0111110
1111111

Ans :

#include<stdio.h>
#include<conio.h>
void main()
{
    int i,j,no;

    clrscr();

    printf("\n Please Enter No : - ");
    scanf("%d",&no);

    printf("\n\n ");
    for(i=0;i<no;i++)
    {
        for(j=0;j<no;j++)
        {
            if(j>=no-1-i)
                printf("1");
            else
                printf("0");
        }
        for(j=1;j<no;j++)
        {
            if(j<=i)
                printf("1");
            else
                printf("0");
        }
        printf("\n ");
    }

    getch();
}

 

3 comments:

Anonymous said...

http://www.djuradj.net/sq/sq_image.html

Anonymous said...

http://demo.webisir.com/lane/index-slider.html

Anonymous said...

Nice blog.

You may also visit cprogrampracticals.blogspot.com for more information about special c programs.

Post a Comment