I just finished this bit of code and wanted to see if there's any way I can improve it. I am trying to learn new, more efficient techniques to code so any criticism would be extremely helpful...Oh! and the point of this program is to make a triangle with x amount of lines
Thanks!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include <iostream>
int main() {
int lines=0;
std::cout<<"Enter the height of the triangle\n";
std::cin>>lines;
for(int c=0; c<lines;c++)
{
int space;
space=lines;
space-=c;
std::cout << std::string( space, ' ' )<<std::string( c*2, '*')<<'*'<<"\n";
}
return 0;
}