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 n be a integer number and initialize by 1.
  5. Repeat step 6 to 8 until all value parsed.
  6. Set i = n and check i>0;
  7. Set j = 0 and check j < i;
  8. Print star Symbol.
  9. End

All Answers

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

JAVA

package programs;  
import java.util.Scanner;  
public class Pattern6   
{  
    public static void main(String[] args)   
    {  
        int i ,j;  
        int n = 6;  
            for(i = n; i>0 ; i-- )  
            {  
                 for(j = 0; j<i ; j++)  
                    {  
                        System.out.print("*");  
                    }  
                         System.out.println("");  
            }      
    }     
} 

 

 

Python

for i in range(1,6):  
    for j in range(1, 6-i+1):  
        print("*"+" "),  
    print("");  

 

C program

#include <stdio.h>  
int main()  
{  
int i ,j;  
    for(i = 5; i>0 ; i-- )  
    {  
     for(j = 0; j<i ; j++)  
    {  
        printf("*");  
    }  
        printf("\n");  
    }  
    return 0;  
}  

 

C# program

using System;  
public class Program  
{  
public static void Main(string[] args)  
{  
for (int row = 5; row >= 1; --row)  
        {  
            for (int col = 1; col <= row; ++col)  
            {  
                Console.Write("*");  
            }  
 Console.WriteLine();  
}   
}  
}  

 

PHP program

<?php  
for ($i = 5; $i >= 1; $i--)  
{  
 for ($j = 1; $j <= $i ; $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... >>
<< Program to print the following pattern (pascal tri...