Q:

pattern program 3 (C language)

0

pattern program 3

All Answers

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

Program - 3

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

#include<stdio.h>

#define MAX	5

int main()
{
    int i,j;
    int space=4;
    /*run loop (parent loop) till number of rows*/
    for(i=0;i< MAX;i++)
    {
	    /*loop for initially space, before star printing*/
	    for(j=0;j< space;j++)
	    {
		    printf(" ");
	    }
	    for(j=0;j<=i;j++)
	    {
		    printf("* ");
	    }
		
	    printf("\n");
	    space--;	/* decrement one space after one row*/
    }
    return 0;
}

Output

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

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

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now