how to write a c++ code to solve this problemes
1- make program using recourison to make a tringle (the first line has one star
the second has 3 stars and the line number n has (2n-1)stars

Firstly, do you know what is recursion?

void a(int z){
    if(z>0){
        a(z-1);
        cout<<z;
    }
}

This is a type of recursion. Calling a(5) will output:

12345

Calling stack:
a(5){a(4){a(3){a(2){a(1){a(0){};
cout<<1;};
cout<<2;};
cout<<3;};
cout<<4;};
cout<<5;}

Any idea on it now? We are not supposed to help you write the whole code, but to teach.

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.