Wednesday, May 20, 2020

Print star in C

  • Program :
#include <stdio.h>
int main()
{
  int row, c, n;
  printf("\n----------------PRINT STAR----------------"); 
  printf("\nEnter the number of rows in pyramid of stars to print:");
  scanf("%d", &n);

  for(row=1;row<=n;row++) 
  {
    for(c=1;c<=n-row;c++) 
      printf(" ");

    for (c=1;c<=2*row-1;c++)
      printf("*");

    printf("\n");
  }

  return 0;
}




  • Output :


No comments:

Post a Comment

Function Overloading in C++

https://monitechvenkat1620.blogspot.com Program : #include <iostream> using namespace std; int c(int x, int y) {   return...