#include<iostream>
using namespace std;
int main()
{
    int x,inpt,ctrl;
    x=1;
    ctrl=1;
    cout<<"Enter a number: ";
    cin>>inpt;
    while(ctrl<=inpt)
    {
               while(x<=ctrl)
               {
                                cout<<x<<" ";
                                x++;
                                }
                                cout<<"\n";
                                ctrl++;
                                x=1;
                                }
    system("pause");
}

can u please help me to invert this triangle?

Set your x and ctrl to whatever you input for inpt.

Then you can run through ( ctrl > 0 )

and output x like

[B]while X is larger than zero then
    print X
    subtract one from X
endwhile[/B]

Decrement your ctrl counter and set X equal to ctrl and you're done

Hi ,
Example >>5
output
5 4 3 2 1
4 3 2 1
3 2 1
2 1
1

If you want this type of output
then initialize x and ctrl by inpt variable

while(ctrl>=1)
{
while(x>=1)
{
cout<<x<<" ";
x--;
}
cout<<"\n";
ctrl--;
x=ctrl;
}

Best Of Luck

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.