Write a C++ program to display fireworks in a ring shape using asteriks (*). Loops, arrays and pointers are to be used. Note: Use cls command. code example
Example 1: print pattern and space in cpp
int num{}, i{1};
cin >> num;
while (i <= num) {
for (int space = 1; space <= (num - i); space++) {
cout << " ";
}
for (int value = 1; value <= (2 * i - 1); value++) {
cout << value;
}
cout << endl;
i++;
}
Example 2: Write a C++ program that displays a Letter Pyramid from a user-provided std::string. Prompt the user to enter a std::string and then from that string display a Letter Pyramid as follows: It's much easier to understand the Letter Pyramid given examples.
#include <iostream>
#include <string>
using namespace std;
int main() {
string user_input {}, pyra {""}, space (user_input.length() - 1, ' ');
cout << "Please enter a sequence of characters... ";
cin >> user_input;
for (size_t i{0}; i < user_input.length(); ++i) {
pyra = user_input.substr(0, i + 1);
cout << space << pyra;
if (pyra.length() == 1) {
cout << space;
} else {
for (auto j {pyra.length()}; j > 0; --j) {
cout << pyra.at(j);
}
}
space.erase(0, 1);
cout << endl;
}
return 0;
}