Square Pattern
#include <iostream>
using namespace std;
int main (){
for (int i=0; i<4 ; i++){
cout<<"* * * * *"<<endl;
}
return 0;
}
Christmas Tree Pattern
#include <iostream>
using namespace std;
int main() {
int n = 5;
for (int i = 1; i <= n; i++) {
for (int j = 0; j < n - i; j++) {
cout << " ";
}
for (int k = 0; k < 2 * i - 1; k++) {
cout << "* ";
}
cout << endl;
}
for (int i = 0; i < 3; i++) {
for (int j = 0; j < n - 2; j++) {
cout << " ";
}
cout << "* * *" << endl;
}
return 0;
}
Diamond Pattern
#include <iostream>
using namespace std;
int main (){
int n=5;
for (int i = 1; i <= n; i++) {
for (int j = 0; j < n - i; j++) {
cout << " ";
}
for (int k = 0; k < 2 * i - 1; k++) {
cout << " * ";
}
cout << endl;
}
for (int i = n - 1; i >= 1; i--) {
for (int j = 0; j < n - i; j++) {
cout << " ";
}
for (int k = 0; k < 2 * i - 1; k++) {
cout << " * ";
}
cout << endl;
}
return 0;
}
Pyramid Pattern
#include <iostream>
using namespace std;
int main (){
int n=5;
for (int i = 1; i <= n; i++) {
for (int j = 0; j < n - i; j++) {
cout << " ";
}
for (int k = 0; k < i*2 - 1 ; k++) {
cout << "*";
}
cout << endl;
}
return 0;
}