TheDeveloperBlog.com

Home | Contact Us

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

Program to Print Pattern 10

Program to Print Pattern 10 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

Program to print the following pattern

To accomplish this task, we need to create two loops and the 2nd loop is to be executed according to the first loop. The first loop is responsible for printing the line breaks whereas the second loop is responsible for printing the stars (*).

Algorithm

  1. Start
  2. Let i be an integer number.
  3. Let j be an integer number.
  4. Repeat step 5 to 7 until all value parse.
  5. Set i = 0 and check i<6;
  6. Set j = 1 and check j <= i;
  7. Print "*".
  8. End

JAVA

package programs;
import java.util.Scanner;
public class Pattern1 
{
    public static void main(String[] args) 
    {
    int i,j,n=7;
        System.out.println("Right angle triangle");
    for(i=1;i<n;i++)
    {
    for(j=1;j<=i;j++)
    {
        System.out.print(" *");
    }
        System.out.println("");
    }
    }
}

Python

k = 1
n=7
for i in range(1, n):
    for j in range(i):
        print("*"),
    print("")

C program

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

C# program

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

PHP program

<?php
$n=6;
for ($i = 1; $i <= $n; $i++)
{
 for ($j = 1; $j <= $i ; $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