//C++ program to print diamond pattern
#include<iostream>
using namespace std;
int main()
{
int rows,i,j;
cout<<"Enter Number of rows ";
cin>>rows;
for(i=1;i<=rows;i++)
{
for(j=rows-i;j>=1;j--)
{
cout<<" ";
}
for(j=1;j<=i;j++)
{
cout<<"* ";
}
cout<<endl;
}
for(i=rows-1;i>=1;i--)
{
for(j=rows-i;j>=1;j--)
{
cout<<" ";
}
for(j=1;j<=i;j++)
{
cout<<"* ";
}
cout<<endl;}
return 0;
}
No comments:
Post a Comment