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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.