ARRAY PROBLEM(what should I do with this one?)

HELLO EVERYONE:)

the program should run like this displaying an asterisks
*
**
***
****
*****

is this program correct?

#include<iostream>
#include<conio.h>
#include<iomanip>

using namespace std;
int main()
{
int rows, cols, numOfAster

cout << "Enter the level of of the asterisks:";
cin >> numOfAster;
cout << "Press any key to see the array:\n";
getch();

for (rows=0; rows < numOfAster; rows++)
{
for (cols=(numOfAster=rows); cols > 0; cols--)
cout << "*";
cout << endl;
}

getch();
return 0;
}


>>>and I also need a program that will display a pyramid or Christmas tree.
*
***
*****
*******
*********
like that .,



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include<iostream>
#include<conio.h>
using namespace std;

int main()
{
int rows, cols, numOfAster;

cout << "Enter the level of of the asterisks:";
cin >> numOfAster;
cout << "Press any key to see the array:\n";
getch();

for (rows=0; rows < numOfAster; rows++)
{
for (cols=0; cols < rows + 1; cols++) cout << "*";
cout << endl;
}

getch();
return 0;
}


You don't need array here.
Last edited on
Topic archived. No new replies allowed.