Making diamond using *

#include<iostream>

using namespace std;

int rows,row;

int main(){

cout<<"enter number of rows "<<endl;

cin>>rows;

row=(rows/2)+1;

for(int x=1;x<=row;x++){

for(int y=1;y<=row-x;y++){

cout<<" ";

}

for(int y=1;y<=(2*x)-1;y++){

cout<<"*";

}
cout<<endl;
}

for(int x=1;x<=(rows/2);x++){

for(int y=1;y<=x;y++){

cout<<" ";

}
for(int y=2*((rows/2)+1-x)-1;y>=1;y--){

cout<<"*";

}
cout<<endl;
}
}
Previous
Next Post »

Comments:

Disqus Shortname