1. Program to print half pyramid using alphabets (Vertical)
#include < iostream>
#include < conio.h>
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<<endl;
};
getch ();
}
2. Program to print half pyramid using alphabets (Horizontal)
#include < iostream>
#include < conio.h>
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<<endl;
};
getch ();
}
3. Print Floyd's Triangle (Binary Number)
#include < iostream>
#include < conio.h>
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<<endl;
};
getch ();
}
4. Print Floyd's Triangle (Horizontal)
#include < iostream>
#include < conio.h>
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<<endl;
};
getch ();
}
5. Inverted top-bottom pyramid using *
#include < iostream>
#include < conio.h>
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 ();
}
6. Inverted top-bottom pyramid using Number
#include < iostream>
#include < conio.h>
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<< " " <<col;
}
cout<<endl;
}
/*
1 2 3
1 2
1
*/
for (row = (n-1 ); row >= 1 ; row--){
for (col = 1 ; col <= row; col++){
cout<<" " <<col;
}
cout<<endl;
}
getch ();
}
7. Program to print full pyramid using *
#include < iostream>
#include < conio.h>
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 ();
}
8. Square full pyramid using *
#include < iostream>
#include < conio.h>
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 ();
}
9. Inverted half pyramid using Numbers
#include < iostream>
#include < conio.h>
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<<endl;
};
getch ();
}
10. Program For Rectangle And Square Star Pattern
#include < iostream>
#include < conio.h>
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<<char (col+64 ) ;// col
}
cout<< endl;
}
}
getch ();
}
10. Program To Print Hollow Rectangle Or Square Star Pattern
#include < iostream>
#include < conio.h>
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<<endl;
}
return 0 ;
}