Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/anower77/all-type-patterns-c-plus-plus

triangle rectangle upper_triangle lower_triangle, reverse_triangle, upper_rectanlge, lower_rectangle, reverse_rectangle
https://github.com/anower77/all-type-patterns-c-plus-plus

all-type-file-download cpp cpp-code patterns problem-solving

Last synced: 7 days ago
JSON representation

triangle rectangle upper_triangle lower_triangle, reverse_triangle, upper_rectanlge, lower_rectangle, reverse_rectangle

Awesome Lists containing this project

README

        

## 1. Program to print half pyramid using alphabets (Vertical)
```c++

#include
#include
using namespace std;
int main()
{
int row, col, n;
cout<< "Enter Integer Number : ";
cin>> n;

for(row = 1; row <= n; row++){

for(col = 1; col <= row; col++){

cout<< " " << char(col+64) ;/// char(col+96) it's return small letter

};
cout<Input : 10
___
## Output -

 

## 2. Program to print half pyramid using alphabets (Horizontal)

```c++

#include
#include
using namespace std;
int main()
{
int row, col, n;
cout<< "Enter Integer Number : ";
cin>> n;

for(row = 1; row <= n; row++){

for(col = 1; col <= row; col++){

cout<< " " << char(row+64) ;/// char(row+96) it's return small letter

};
cout<Input : 10
___
## Output -

 

## 3. Print Floyd's Triangle (Binary Number)

```c++
#include
#include
using namespace std;
int main()
{
int row, col, n;

cout<< "Enter Integer Number : ";
cin>> n;

for(row = 1; row <= n; row++){

for(col = 1; col <= row; col++){

cout<< " " << (col%2) ;

};
cout<Input : 10
___

## Output -

 

## 4. Print Floyd's Triangle (Horizontal)

```c++

#include
#include
using namespace std;
int main()
{
int row, col, n;

cout<< "Enter Integer Number : ";
cin>> n;

for(row = 1; row <= n; row++){

for(col = 1; col <= row; col++){

cout<< " " << (row%2) ;

};
cout<Input : 10
___

## Output -

 

## 5. Inverted top-bottom pyramid using *

```c++

#include
#include
using namespace std;
int main()
{
while (true)
{

int row, col, n;
cout<< "Enter N : ";
cin>> n;
for (row = 1; row <= n; row++){

for(col = 1; col <= row; col++)
{
cout<< "* ";
}
cout << endl;
}

for (row = n-1; row >= 1; row--)
{

for (col = 1; col <= row; col++)
{
cout<< "* ";
}
cout<< endl;
}

}
return 0;
getch();
}

```

## Input : 10
___

## Output -

 

## 6. Inverted top-bottom pyramid using Number

```c++

#include
#include
using namespace std;
int main()
{
int col, row, n;
cout<<"Enter Number : ";
cin>> n;
/*
1
1 2
1 2 3
*/

for (row = 1; row <= n; row++){
for (col = 1; col <= row; col++){
cout<< " "<= 1; row--){
for (col = 1; col <= row; col++){
cout<<" "<Input : 10
___

## Output -

 

## 7. Program to print full pyramid using *

```c++

#include
#include
using namespace std;
int main()
{
while(true){

int n, col, row;
cout<< "Enter N : ";
cin>> n;
for (row = 1; row <= n; row++)
{

//Printing spaces
for (col = 1; col <= n-row; col++)
{

cout<< " ";

};
//Printing star
for (col =1; col <= 2*row-1; col++){

cout<< "* ";
};
cout<< endl;
}

}//End while loop
getch();
}

```

## Input : 10
___

## Output -

 

## 8. Square full pyramid using *

```c++

#include
#include
using namespace std;
int main()
{
while(true){

int n, col, row;
cout<< "Enter N : ";
cin>> n;
for (row = 1; row <= n; row++)
{

//Printing spaces
for (col = 1; col <= n-row; col++)
{

cout<< " ";

};
//Printing star
for (col =1; col <= 2*row-1; col++){

cout<< "* ";
};
cout<< endl;
}

///Reverse Pyramid
for (row = n-1; row >= 1; row--)
{

//Printing spaces
for (col = 1; col <= n-row; col++)
{

cout<< " ";

};
//Printing star
for (col =1; col <= 2*row-1; col++){

cout<< "* ";
};
cout<< endl;
};

}//End while loop
getch();
}

```

## Input : 10
___

## Output -

 

## 9. Inverted half pyramid using Numbers

```c++

#include
#include
using namespace std;
int main()
{
int row, col, n;
cout<< "Enter Integer Number : ";
cin>> n;

for(row = n; row >= 1; row--){

for(col = 1; col <= row; col++){

cout<< " " << row;
};
cout<Input : 9
___

## Output -

 

## 10. Program For Rectangle And Square Star Pattern

```c++

#include
#include
using namespace std;
int main()
{
while(1){
int n, col, row;
cout<<"Enter Number : ";
cin>>n;
for (row = 1; row <= n; row++)
{

///spacing
for (col = 1; col <= n-row; col++)
{
cout<< " ";
}
///number
for (col = 1; col <= row; col++)
{
cout<Input : 10
___

## Output -

## 10. Program To Print Hollow Rectangle Or Square Star Pattern

```c++

#include
#include
using namespace std;
int main()
{
int rows,columns,i,j;
cout<<"Enter the number of rows : ";
cin>>rows;
cout<<"Enter the number of columns : ";
cin>>columns;
for (i=1; i<=rows; i++){
for (j=1; j<=columns; j++){
if(i==1||i==rows||j==1||j==columns){
cout<<"*";
}else{
cout<<" ";
}
}
cout<Input : 10 & 20
___

## Output -