TheDeveloperBlog.com

Home | Contact Us

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

Program to Print Pattern 17

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

<< Back to PROGRAM

Program to print the following pattern

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 9 until all value parsed.
  6. Set i = 0 and check i<6;
  7. Set j = 1 and check j <= i;
  8. Print number n.
  9. Then n++;
  10. End

In this program, we are creating a right-angled triangle of numbers in increasing order. We are creating two loops, and 2nd loop is executing according to the first loop, inside 2nd loop printing the number row-wise i loop times.

1
2 3
4 5 6
7 8 9 10


JAVA

package programs;
public class pattern13 
{
    public static void main(String[] args) 
    {
        int n=1;
        for(int i=0;i<6;i++)
        {
             for(int j=1;j<i;j++)
             {
                 System.out.print(" "+n);
               n++;
             }
             System.out.println("");
        }
    }
}

Python

n = 5
k=1
for i in range(1,n):
    for j in range(0,i):
        print(k),
        k=k+1
    print("")

C program

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

C# program

using System;
public class Program
{
	public static void Main(string[] args)
    {
        int i, j, rows, k = 1; 
        Console.Write("\n\n");
        rows = 4;
        for (i = 1; i <= rows; i++)
        {
            for (j = 1; j <= i; j++)
                Console.Write("{0} ", k++);
            Console.Write("\n");
        }  
    }
}  

PHP program

<?php
$rows = 5;
$n = 1;
for($i = $rows; $i != 0; $i--)
{
    for($space = 0; $space < $rows - $i; ++$space)
    {
        echo $n;
          $n++;
    }
  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