0

This is the coding i have done bt its nt printing in 'H' pattern.
Can anybody help m 2 print dis..??

This is the 'H' pattern i want 2 print :

*    * 
**  **
******
**  **
*    *

Coding :

#include<stdio.h>
#include<conio.h>
int main()
{
    int i, j, k;
    clrscr();
    for(i=0; i<5; i++)
    {
        for(j=0; j<=i; j++)
            printf("*");
        for(k=0; k<6-(2*j); k++)
            printf(" ");
        for(j=0; j<=i; j++)
            printf("*");
        printf("\n");
    }
    for(i--; i>0; i--);
    {
        for(j=0; j<i; j++)
            printf("*");
        for(k=0; k<6-(2*i); k++)
            printf(" ");
        for(j=0; j<i; j++)
            printf("*");
        printf("\n");
    }
    getch();
    return(0);
}

Edited by mike_2000_17: Fixed formatting

2
Contributors
1
Reply
3
Views
6 Years
Discussion Span
Last Post by prvnkmr449
0

Use this simple loop

for(i=0;i<9;i++)
{
	for(j=0;j<9;j++)
	{
	if(j>2&&j<6&& i<3||j>2&&j<6&&i>5)	printf(" ");
	else printf("*");
	}
	printf("\n");
}

Best Of luck

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.