Pyramid Pattern Programs
Pyramid Pattern Programs
*
* *
* * *
* * * *
* * * * *
Source Code
#include <iostream>
using namespace std;
int main()
{
int rows;
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
Source Code
#include <iostream>
using namespace std;
int main()
{
int rows;
A
B B
C C C
D D D D
E E E E E
Source Code
#include <iostream>
using namespace std;
int main()
{
char input, alphabet = 'A';
cout << "Enter the uppercase character you want to print in the last row:
";
cin >> input;
* * * * *
* * * *
* * *
* *
*
Source Code
#include <iostream>
using namespace std;
int main()
{
int rows;
return 0;
}
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
Source Code
#include <iostream>
using namespace std;
int main()
{
int rows;
return 0;
}
Programs to display pyramid and inverted pyramid using *
and digits
*
* * *
* * * * *
* * * * * * *
* * * * * * * * *
Source Code
#include <iostream>
using namespace std;
int main()
{
int space, rows;
while(k != 2*i-1)
{
cout << "* ";
++k;
}
cout << endl;
}
return 0;
}
1
2 3 2
3 4 5 4 3
4 5 6 7 6 5 4
5 6 7 8 9 8 7 6 5
Source Code
#include <iostream>
using namespace std;
int main()
{
int rows, count = 0, count1 = 0, k = 0;
while(k != 2*i-1)
{
if (count <= rows-1)
{
cout << i+k << " ";
++count;
}
else
{
++count1;
cout << i+k-2*count1 << " ";
}
++k;
}
count1 = count = k = 0;
* * * * * * * * *
* * * * * * *
* * * * *
* * *
*
Source Code
#include <iostream>
using namespace std;
int main()
{
int rows;
return 0;
}
Example 9: Print Pascal's triangle
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
Source Code
#include <iostream>
using namespace std;
int main()
{
int rows, coef = 1;
return 0;
}
Example 10: Print Floyd's Triangle.
1
2 3
4 5 6
7 8 9 10
Source Code
#include <iostream>
using namespace std;
int main()
{
int rows, number = 1;
return 0;
}