Q:

write program to generate following pattern

0

write program to generate following pattern

      *

    *  *

 *   *   *

All Answers

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

Program:

#include<stdio.h>
int main()
{
    int n, r, c, s;

    printf("Enter number of rows: ");
    scanf("%d",&n);

    for(r=1;r<=n;r++)
    {
      for(s=1;s<=n-r;s++) printf(" ");
      for(c=1;c<=(2*r-1);c++) printf("*");

      printf("\n");
    }

    return 0;
}

Output:

  Enter number of rows: 3
  *
 ***
*****

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

total answers (1)

C Programming Exercises With Solutions

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Write a program to input from user (5 subjects) su... >>
<< write program to generate following pattern...