REally Simple right?

hk3008

Distinguished
Jan 29, 2012
43
0
18,580
ok so I have

#include<cmath>
#include<iostream>

using namespace std; // So the program can see cout and endl

int main()
{
int n = 4;
int line, stars, loop;
for (line = 1; line <= n; line++)
{
stars = n - line + 1;
for (loop = 1; loop <= stars; loop++)
cout << "*";

}

}

It works fine no errors except 1 it doesnt stay on screen the dos windo immedietly closes in a blink of an eye y is that? how do I make it stay open and display the shape and two how would Imake the triangle go different like with the main edge towrds awat and to the side?
 

randomizer

Distinguished

What did you expect it to do? It completed all of its instructions, so it has no reason to remain open. Remember, software is dumb and doesn't do anything except what you tell it to do, and you haven't told it to wait at the end.

Never assume that your program will do what you want it to do, only what you told it to do (which may not actually be what you want it to do if your logic is wrong).