**5.21 (Display numbers in a pyramid pattern) Write a nested for loop that prints the following output:
Sat Oct 24 2020 17:58:24 GMT+0000 (UTC)
Posted by
@mahmoud hussein
#c++
#include <iostream>
#include<cmath>
#include<ctime>
#include<string>
#include <iomanip>
#include <fstream>
using namespace std;
int main()
{
for (int i = 0; i < 8; i++)
{
for (int k = 0; k <= i; k++)
{
cout << " ";
}
for (int j = i; j < 8; j++)
{
cout <<" "<< static_cast<char>(j+97-i);
}
for (int j = 7; j >= i; j--)
{
cout << " " << static_cast<char>(j + 97 - i);
}
cout << "\n";
}
}
content_copy Copy
http://cpp.sh/
Comments