Making Patterns

In this page we will discuss about patterns,But before starting the pattern programs we will discuss the following questions.
Both questions are from my personal experience So it is possible that some do not agree with this,

Is it mandatory to create patterns programs?
Is Patterns programs are different from other normal Programs?.
How to make patterns? for beginners, sometimes making patterns maybe hard.

Let’s discuss about them,

Patterns Programs will improve your Programming skill 

If you are a beginner and you want to improve your programming skill, then it becomes mandatory to make patterns related programs.
doesn’t matter that all your concepts have not been completed yet. Maybe Quality is better than completing the concept.

In any programming language, when we talk about the basic concept, the control-statement has a major role in it.
Control-statement is not just a definition where condition become true than body will be execute and become false body skip. it is a powerful feature of any Programming language,

We use the control statement to create logics. Which is the basic structure of a program.
The data structure is completely dependent on the control-statement.
Using the control-statement other concept i.e. with an array gives us other features of the array- sorting array-elements, binary search, tree, searching-elements, accessing elements manually etc.

There are all projects and complex programs in this website. In them, 80% control-statement has been used while Oops concept has been used only to manage the large code.

Example- making heart,swastik,chrismats tree, student management, loading bars, conver to numeric value into character form etc.

According to my experience, If you can make any patterns then you can make any programs. This improves your programming skills to a great extent.

so if you do not learn the patterns program in any programming language. So it may take a long time to get improved in your programming skill. It does not matter which language you worked on.

Patterns vs other Programs

Let’s understand it from an example.

There is a program in which, we have to add any two numbers. So how do we do it?

Simple, declare two variables using the arithmetic operator with them.

But how did we do it?

Because we already know how to add numbers in the real world.

just like that,

  • How do divisions and averages calculate?
  • What is LCM and HCF?
  • What are negative and positive numbers.
  • How does a number table come out?

There are many such examples available and we have practiced all these examples before we start programming. We have only applied them in programs with the help of some operators.

and about patterns-

  • There are no specific operators to making patterns like- To add two numbers, only + sign is used.
  • Yes, we use different operators to create patterns, so there can be hundreds of ways to create the same patterns.
  • Because the same patterns can be made in many ways, meaning, the possibilities are obtained.

How to make patterns?

 Now we know how important pattern exercises are.

But here now, the question arises how to make patterns?

For beginners, pattern programs can be a bit difficult at the beginning, but when you move forward, you will get both fun and interesting.for beginners  To make a pattern, first draw it on a paper.

You have two ways to learn patterns programs,

  • Create the same pattern in different ways.
  • Draw different patterns in the same way.

Maybe both of them become a bit complicated for now?

 Don’t worry when you make the patterns, then you will understand both these things. Forget it, for now.

We have already discussed that a pattern can be made in many ways. Here we will use the most commonly used method.

That is ROW and COLUMN.

Let us understand this with making a simple pattern,

Here we have created two programs.

 In the first program, we have drawn a right angle,

Here is the code,

#include<iostream.h>
#include<conio.h>

 void main()
  {
    int row,i,j;
    clrscr();
    cout<<"Enter the number: "; cin>>row;

     for(i=1; i<=row; i++) // row
      {
	for(j=1;j<=i;j++)  // column
	 {
	   cout<<" "<<j;    // print j value
	 }
	cout<<endl;
      }

   getch();
 }
OUTPUT:-
Enter Number of rows: 5

 1
 1 2
 1 2 3
 1 2 3 4
 1 2 3 4 5

And here is the explanation

making-triangle

In the program we have used two loops, the first is outer-loop and second is inner-loop.

The first loop is used for the row of number meaning, what will be the size of the pattern.

1stloop-pattern

While the second loop will print the pattern

2nd-loop

Here is another one where we make a pyramid,

#include<iostream.h>
#include<conio.h>

 void main()
  {
   int row,i,j,k;
   clrscr();
   cout<<"Enter the number: ";
   cin>>row;

   cout<<endl;

    for(i=1;i<=row;i++)
     {
       for(j=1;j<=row-i;j++)
	   cout<<" ";

       for(k=1; k<=i*2-1; k++)
	   cout<<k;

       cout<<endl;
     }

   getch();
 }
OUTPUT:-
Enter the number: 5

    1
   123
  12345
 1234567
123456789

explanation-

this program is little bit different from above pattern. as you can seen this pyramid consist of two pattern,

pyramid

Here we used three loop to make pyramid,

In this program, the first loop is representing the row of numbers as in the before program,

1-loop

While the second loop is printing a blank pattern, because we have assigned a space to the variable j,

2ndpyramid

And the third loop will print the pyramid,

pyramid-making

In all the patterns given in this website, the first loop has been taken as a number of rows from which the input will be done by the user,

so the size of the pattern will depend on the user-input i.e. the higher digit will be make a large pattern.

In this website you will find the following pattern programs,

BASIC PATTERNS

patt
1
2
three
3
four
4
five
5
six
6
seven
7
eight
8
nine
9
ten
10
eleven
11
twelve
12
thirteen
13
14
fifteen
15
sixteen
16
seventeen
17
seventeen
18
nineteen
19
twenty
20

COMPLEX PATTERNS

ttwenty-one
21
twenty-two
22
twenty-four
23
twenty-five
24
twenty-six
25
twenty-nine
26
twenty-three
27
twenty-eight
28
twenty-seven
29
30
thirty-two
Isoscles Triangle
thirty-three
Right-Aangle
thirty-four
Obtuse Triangle
thirty
31
Equilateral-angle
Equilateral Triangle
Equilateral2-angle
Equilateral Triangle
Hexagon
Hexagon
solid-square
Solid-Squre
diamond-in-cpp
Daimond
Lattu-in-cpp
Lattu
swastik
Swastik
chirsmats-tree
Christmas
heart
Heart

here giving these patterns only means that we can create any pattern/programs from the control-statement.

Whether it is a simple pattern like a triangle, square, right angle etc or other complex patterns like a heart, tree, shiv-trishul, Himalayas, maps, etc.

The best way to learn pattern programs is to create a simple patterns in different ways, Means find different possibilities.Other patterns will be understood by you yourself. You will not have to understand them separately.

 

optional

In the patterns, apart from the * sign, we can also use many more signs. Here are some of the below signs –

patterns

But in this, the cout -statement will not be used. Here we will use another function cprintf().

  Example

   cprintf("%c", number);

Let’s try this with a example here, where we create a square.

#include<conio.h>
#include<iostream.h>

 void main()
  {
   int i,j,n;
   clrscr();
   cout<<"Enter Number of rows: "; cin>>n;

    for(i=1; i<=n; i++)
     {
       for(j=1; j<=n*2; j++)
	{
	     cprintf("%c",176);     
        }
       cout<<endl;
     }

    getch();
  }
OUTPUT:-
Enter Number of rows: 5

°°°°°°°°°°
°°°°°°°°°°
°°°°°°°°°°
°°°°°°°°°°
°°°°°°°°°°