TheDeveloperBlog.com

Home | Contact Us

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

Program to Print Pattern 11

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

A
B B
C C C
D D D D
E E E E E

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 parsed.
  5. Set i = 0 and check i<4;
  6. Set j = 0 and check j <= i;
  7. Print char(65+i).
  8. End.

To accomplish this task, we need to use two loops, the first loop is responsible for printing the line breaks whereas the second loop is responsible for printing the alphabet.


JAVA

public class Pattern 
{
    public static void main(String[] args) 
    {
        int n = 4;
        for(int i = 0 ; i <= n ; i++)
        {
        for(int j = 0 ; j <= i ; j++)
        {
            System.out.print(" "+(char)(65 + i));
        }
            System.out.println("");
        }
    }
}

Python

k = 1
for i in range(1, 6):
    for j in range(65, 65+i):
        print(chr(64+i)),
    print("")

C program

#include <stdio.h>
int main()
{
    int n = 69;
 for(int i = 65 ; i <= n ; i++)
{
    for(int j = 65 ; j <= i ; j++)
    {
        printf("%c",i);
    }
        printf("\n");
    }
    return 0;
}

C# program

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

PHP

<?php
for ($i = 65; $i <= 69; $i++)
{
 for ($j = 65; $j <= $i ; $j++)
  {
   echo chr($i);
  }
   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