0
How to make a pyramid program by using * sign?
* * * * * * * * * this is the format....plz provide me the coding for this program
2 Antworten
+ 2
I think you mean to write a diamond pattern:
#include <iostream>
using namespace std;
int main()
{
int i,j,k,n;
cout<<"Enter the number of lines to be printed: ";
cin>>n;
cout<<endl;
for(i=0;i<n;i++)
{
for(j=0;j<(n-i-1);j++)
cout<<" ";
for(k=0;k<(2*i+1);k++)
cout<<"*";
cout<<endl;
}
for(i=0;i<n-1;i++)
{
for(j=0;j<=i;j++)
cout<<" ";
for(k=(2*n-2*i-3);k>0;k--)
cout<<"*";
cout<<endl;
}
return 0;
}
+ 1
thanks # isko