C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Program to print the following patternAlgorithm
JAVApublic class Pattern12 { public static void main(String[] args) { int size ; size =6; for (int i = size; i != 0; i--) { for (int j = 0; j<size-i; j++) { System.out.print(" "); } for (int k = 00; k < (2 * i - 1); k++) { System.out.print("*"); } System.out.println(); } } } Pythoni=1 for j in range(11,0,-2): print(i*' '+j*'*') i = i+1 C program#include <stdio.h> int main() { int size = 6; for (int i = size; i != 0; i--) { for (int j = 0; j<size-i; j++) { printf(" "); } for (int k = 0; k < (2 * i - 1); k++) { printf("*"); } printf("\n"); } } C# programusing System; public class Program { public static void Main() { int num, i, k, count = 1; num=7; for (k = 1; k <= num - 1; k++) { for (i = 1; i <= count; i++) Console.Write(" "); count++; for (i = 1; i <= 2 * (num - k) - 1; i++) Console.Write("*"); Console.WriteLine(); } Console.ReadLine(); } } PHP program<?php for($i=9;$i>=1;$i--){ for ($d=0; $d <= 9-$i; $d++) { echo " "; } for($j=$i;$j>=1;$j--){ echo "�"."* �"; } echo "<br>"; } ?>
Next TopicProgram to Print pattern 15
|