Q:

pattern program 5 (C language)

belongs to collection: Pattern Programs in C

0

pattern program 5

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program - 5

/*C program to print following Pyramid:
    **********
    ****  ****
    ***    ***
    **      **
    *        *
*/

#include<stdio.h>

#define MAX	5

int main()
{
	int i,j;
	int space=0;
	/*run loop (parent loop) till number of rows*/
	for(i=MAX;i>0;i--)
	{
		/*print first set of stars*/
		for(j=0;j< i;j++)
		{
			printf("*");
		}
		for(j=0;j< space;j++)
		{
			printf(" ");
		}
		/*print second set of stars*/
		for(j=0;j< i;j++)
		{
			printf("*");
		}
		
		printf("\n");
		space+=2;
	}
    return 0;
}

Output

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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

pattern program 6 (C language)... >>
<< pattern program 4 (C language)...