All Number Patterns in C++ programming Language

Introduction to Number Patterns in C++

Students who are learning any programming language must practice printing different patterns in order to comprehend and apply logical reasoning and flow control knowledge in a useful and enjoyable manner. Learn Number Patterns in C++

In C++, patterns are the fundamental programs that serve as the foundation for learning any language.

These applications are implemented using two or three flow control loops.

Typically, pattern applications employ a minimum of two loops, one to build a row and another to create a column.

The number of rows is represented by the first loop, which is the outer loop, and the number of columns is represented by the second loop, which is the inner loop.

Following is a description of the Pattern’s fundamental structure in the C++ language:

Number pattern : 1

1
12
123
1234
12345

``````#include<iostream>
using namespace std;
int main()
{
int i, j;
for(i=1; i<=5; i++)
{
for(j=1; j<=i; j++)
{
cout<<j;
}
cout<<endl;
}
return 0;
}``````

Number pattern : 2

5
45
345
2345
12345

``````#include<iostream>
using namespace std;
int main()
{
int i, j;
for(i=5; i>=1; i--)
{
for(j=i; j<=5; j++)
{
cout<<j;
}
cout<<endl;
}
return 0;
}``````

Number pattern : 3

12345
1234
123
12
1

``````#include<iostream>
using namespace std;
int main()
{
int i, j;
for(i=5; i>=1; i--)
{
for(j=1; j<=i; j++)
{
cout<<j;
}
cout<<endl;
}
return 0;
}``````

Number pattern : 4

12345
2345
345
45
5

``````#include<iostream>
using namespace std;
int main()
{
int i, j;
for(i=1; i<=5; i++)
{
for(j=i; j<=5; j++)
{
cout<<j;
}
cout<<endl;
}
return 0;
}``````

Number pattern : 5

``````54321
4321
321
21
1``````
``````#include<iostream>
using namespace std;
int main()
{
int i, j;
for(i=5; i>=1; i--)
{
for(j=i; j>=1; j--)
{
cout<<j;
}
cout<<endl;
}
return 0;
}``````

Number pattern : 6

54321
5432
543
54
5

``````#include<iostream>
using namespace std;
int main()
{
int i, j;
for(i=1; i<=5; i++)
{
for(j=5; j>=i; j--)
{
cout<<j;
}
cout<<endl;
}
return 0;
}``````

Number pattern : 7

1
21
321
4321
54321

``````#include<iostream>
using namespace std;
int main()
{
int i, j;
for(i=1; i<=5; i++)
{
for(j=i; j>=1; j--)
{
cout<<j;
}
cout<<endl;
}
return 0;
}``````

Number pattern : 8

5
54
543
5432
54321

``````#include<iostream>
using namespace std;
int main()
{
int i, j;
for(i=5; i>=1; i--)
{
for(j=5; j>=i; j--)
{
cout<<j;
}
cout<<endl;
}
return 0;
}``````

Number pattern : 9

1
22
333
4444
55555

``````#include<iostream>
using namespace std;
int main()
{
int i, j;
for(i=1; i<=5; i++)
{
for(j=1; j<=i; j++)
{
cout<<i;
}
cout<<endl;
}
return 0;
}``````

Number pattern : 10

5
44
333
2222
11111

``````#include<iostream>
using namespace std;
int main()
{
int i, j;
for(i=5; i>=1; i--)
{
for(j=5; j>=i; j--)
{
cout<<i;
}
cout<<endl;
}
return 0;
}``````

Number pattern : 11

1234567
12345
123
1

``````#include<iostream>
using namespace std;
int main()
{
int i, j;
for(i=7; i>=1; i-=2)
{
for(j=1; j<=i; j++)
{
cout<<j;
}
cout<<endl;
}
return 0;
}``````

Number pattern : 12

12345
4321
123
21
1

``````#include<iostream>
using namespace std;
int main()
{
int i,j,k;
for(i=5; i>=1; i--)
{
if(i%2==1) k=1;
else k=i;
for(j=1; j<=i; j++)
{
cout<<k;
if(i%2==1) k++;
else k--;
}
cout<<endl;
}
return 0;
}``````

Number pattern : 13

55555
4444
333
22
1

``````#include<iostream>
using namespace std;
int main()
{
int i, j;
for(i=5; i>=1; i--)
{
for(j=1; j<=i; j++)
{
cout<<i;
}
cout<<endl;
}
return 0;
}``````

Number pattern : 14

11111
2222
333
44
5

``````#include<iostream>
using namespace std;
int main()
{
int i, j;
for(i=1; i<=5; i++)
{
for(j=5; j>=i; j--)
{
cout<<i;
}
cout<<endl;
}
return 0;
}``````

Number pattern : 15

55555
45555
34555
23455
12345

``````#include<iostream>
using namespace std;
int main()
{
int i, j, k;
for(i=5; i>=1; i--)
{
k = i;
for(j=1; j<=5; j++)
{
if(k <= 5)
{
cout << k;
}
else
{
cout << "5";
}
k++;
}
cout << endl;

}
return 0;
}``````

Number pattern : 16

1
01
101
0101

``````#include<iostream>
using namespace std;
int main()
{
int i, j;
for(i=1; i<=4; i++)
{
for(j=i; j>=1; j--)
{
cout<< j%2;
}
cout<<endl;
}
return 0;
}``````

Number pattern : 17

1
24
135
2468
13579

``````#include<iostream>
using namespace std;
int main()
{
int i, j, k;
for(i=1; i<=5; i++)
{
if(i%2==0)
{
k=2;
}
else
{
k = 1;
}
for(j=1; j<=i; j++,k+=2)
{
cout<<k;
}
cout<<endl;
}
return 0;
}``````

Number pattern : 18

``````13579
3579
579
79
9``````
``````#include<iostream>
using namespace std;
int main()
{
int i,j;
for(i=1;i<=9;i+=2)
{
for(j=i;j<=9;j+=2)
{
cout<<j;
}
cout<<endl;
}
return 0;
}``````

TaggedAll number patterns using C programming Languagec programsC++ Programs PracticeNumber Patterns in C++

Java Final keyword

Introduction : java final keyword The final keyword present in Java programming language is generally used for restricting the user. …

C++ Memory Management: new and delete

C++ Memory Management We know that arrays store contiguous and the same type of memory blocks, so memory is allocated …