Computer Science, asked by sambitpatra8272, 11 months ago

WAP(write a program) to display the following star pattern..

Attachments:

Answers

Answered by amritanshu6
1
Pattern program in C

#include <stdio.h>

int main()

{

  int row, c, n, s;

printf("Enter the number of rows in pyramid of stars you wish to see\n");

  scanf("%d", &n);

s = n;

for (row = 1; row <= n; row++)  // Loop to print rows

  {

    for (c = 1; c < s; c++)  // Loop to print spaces in a row

      printf(" ");

s--;

for (c = 1; c <= 2*row - 1; c++) // Loop to print stars in a row

      printf("*");

printf("\n");

  }

return 0;

}
public class Triangular

{

public static void main(String args[])

{

int n, i, j, space = 1;

System.out.print("Enter the number of rows: ");

Scanner s = new Scanner(System.in);

n = s.nextInt();

space = n - 1;

for (j = 1; j <= n; j++)

{

for (i = 1; i <= space; i++)

{

System.out.print(" ");

}

space--;

for (i = 1; i <= (2 * j - 1); i++)

{

System.out.print("*");

}

System.out.println("");

}

}

}


PLEASE MARK MY ANSWER AS A BRAINLIEST ANSWER.

sambitpatra8272: Please do it in java . I request
sambitpatra8272: My friend
sambitpatra8272: Amritansu
sambitpatra8272: I have forgotten to tell that it should be a java program but please help me out
Answered by sanjudnath
8

Answer:

We will create different patterns or a geometrical shape such as triangle, square, etc. We are going to cover the following patterns.

Similar questions