If you have any query feel free to chat us!
Happy Coding! Happy Learning!
Certainly! Let's continue with a few more interesting patterns:
- Pattern 6 - Hollow Square:
markdownCopy code
**** * * * * ****
cppCopy code
#include <iostream> int main() { int n = 4; // Number of rows for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (i == 1 || i == n || j == 1 || j == n) std::cout << "*"; else std::cout << " "; } std::cout << std::endl; } return 0; }
- Pattern 7 - Right Triangle (Inverted):
markdownCopy code
**** *** ** *
cppCopy code
#include <iostream> int main() { int n = 4; // Number of rows for (int i = 1; i <= n; i++) { for (int j = 1; j <= i - 1; j++) { std::cout << " "; } for (int k = 1; k <= n - i + 1; k++) { std::cout << "*"; } std::cout << std::endl; } return 0; }
- Pattern 8 - Number Pyramid:
Copy code
1 232 34543 4567654
cppCopy code
#include <iostream> int main() { int n = 4; // Number of rows for (int i = 1; i <= n; i++) { int num = i; // Print spaces for (int j = 1; j <= n - i; j++) { std::cout << " "; } // Print increasing numbers for (int k = 1; k <= 2 * i - 1; k++) { std::cout << num; if (k < i) num++; else num--; } std::cout << std::endl; } return 0; }
- Pattern 9 - Butterfly Pattern:
markdownCopy code
* * ** ** *** *** **** **** ********** **** **** *** *** ** ** * *
cppCopy code
#include <iostream> int main() { int n = 5; // Number of rows // Upper part of the butterfly for (int i = 1; i <= n; i++) { for (int j = 1; j <= i; j++) { std::cout << "*"; } for (int k = 1; k <= 2 * (n - i); k++) { std::cout << " "; } for (int l = 1; l <= i; l++) { std::cout << "*"; } std::cout << std::endl; } // Lower part of the butterfly for (int i = n; i >= 1; i--) { for (int j = 1; j <= i; j++) { std::cout << "*"; } for (int k = 1; k <= 2 * (n - i); k++) { std::cout << " "; } for (int l = 1; l <= i; l++) { std::cout << "*"; } std::cout << std::endl; } return 0; }
Feel free to modify the value of
n
in each pattern to change the size of the pattern. You can experiment with different patterns and create your own variations as well!
Comments: 2
SCIAKU Team please upload 1st video of TREE please please please, please
I bought this course, it worth it!
Hi i want to buy this course but you dont have master card payment method please let me know how i can buy it
Dear mk.info.work, Now we have all types of payment options. If you need to purchase just checkout our official website