A pattern programs code on C plus plus
#include <iostream.h>int main(){int n = 5;int x = n;for(int i =1; i <= n; i++){for(int j =1; j < 2 * n; j++){if (j == x || j == n + i - 1){cout<<"*";}else if (j >= x && j <= n + i - 1 && i == n / 2 + 1){cout<<"*";}else{cout<<" ";}}cout<<endl;x--;}return 0;}
Output--
*
* *
* * * *
* *
* *
Post a Comment