0

How to make a pyramid program by using * sign?

* * * * * * * * * this is the format....plz provide me the coding for this program

15th Nov 2016, 5:52 PM
Manjeet Kumar
Manjeet Kumar - avatar
2 Respostas
+ 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; }
16th Nov 2016, 7:57 PM
Isko
+ 1
thanks # isko
17th Nov 2016, 11:32 AM
Manjeet Kumar
Manjeet Kumar - avatar