Q:

Program to print the following pattern

belongs to collection: Pattern Programs

0

Algorithm

  1. Start
  2. Let i be an integer number.
  3. Let j be an integer number.
  4. Let size be an integer number and initialize by 6.
  5. Repeat step 6 to 10 until all value parsed.
  6. Set i = size and check I != 0;
  7. Set j = 0 and check j <= size-i;
  8. Print space.
  9. Set k = 0 and check k <= 2*i-1;
  10. Print star symbol.
  11. End

All Answers

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

JAVA

public 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();  
    }  
    }  
}  

 

Python

i=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# program

using 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>";  
  }  
?>  

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

total answers (1)

Program to print the following pattern (pascal tri... >>
<< Program to print the following pattern...