TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

Program to Print Pattern 19

Program to Print Pattern 19 on fibonacci, factorial, prime, armstrong, swap, reverse, search, sort, stack, queue, array, linkedlist, tree, graph, pattern, string etc.

<< Back to PROGRAM

Program to show a triangle of numbers pattern

Program to show a triangle of numbers pattern

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 8 to 16 until all value parsed.
  6. Set i = 0 and check I <= size+1;
  7. Set j = size and check j > 1;
  8. Print space.
  9. Set k = 1 and check k < 2*i-1;
  10. Print "*".
  11. End

JAVA program

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

PHP program

<?php
for ($i=1; $i<=5; $i++)        
{ 
for ($k=5; $k>$i; $k--) 
{ 
echo "�"; 
}
for($j=1;$j<=(2*$i)-1;$j++)
{
echo " *";  
}
echo "<br>";
} 
?>





Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf