0

I want to print a pyramid like this.....
*****
****
***
**
*
This is my code.....

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
    int i,j;
    int b;
    char* sp=" ";
    cin>>j;
    for(int a=j;a>=1;a--)
 {   for( b=a;b>=1;b--)
    cout<<"*";
    cout<<endl;
    for(int k=1;k<b;k++)
    cout<<sp;
    
    }
    
    getch();
    return 0;
}

But it does not print that pyramid.Please help.

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by Anuradha Mandal
0

First of all, there is no need for 3 loops, second, think if so many integers are really necessary.

Edited by nuclear: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.