package programs;
import java.util.Scanner;
public class Pattern8
{
public static void main(String[] args)
{
int size = 0;
Character c;
System.out.println();
size = 5;
int i, j, k;
for (i = 0; i < size + 1; i++) { for (j = size; j > i; j--) {
System.out.print(" ");
}
for (k = 0; k < (2 * i - 1); k++) {
System.out.print("*");
}
System.out.println();
}
}
}
Python
for i in range(1,6):
for j in range(1, 6-i+1):
print(" ", end='')
for k in range(0, 2*i-1):
print("*"),
print("")
C program
#include <stdio.h>
int main()
{
int i, j, k;
for (i = 0; i < 5 + 1; i++)
{
for (j = 5; j > i; j--)
{
printf(" ");
}
for (k = 0; k < (2 * i - 1); k++)
{
printf("*");
}
printf("\n");
}
return 0;
}
C# program
using System;
public class Program
{
public static void Main(string[] args)
{
int n, i, k, count = 1;
n = 5;
count = n - 1;
for (k = 1; k <= n; k++)
{
for (i = 1; i <= count; i++)
Console.Write(" ");
count--;
for (i = 1; i <= 2 * k - 1; i++)
Console.Write("*");
Console.WriteLine();
}
}
}
JAVA program
Python
C program
C# program
PHP program
need an explanation for this answer? contact us directly to get an explanation for this answer