Hey guys,
I need to print out character symbols for this program. I need to print 2 different shapes of symbols. For the first shape, I have to print out a triangle, represented by the "*" in the nested for loop. I need to print out a square shape using "&" symbols but using a nested while loop. The target is such that if n=3, the output will be as follows:
*
&
*
**
&&
&&
*
**
***
&&&
&&&
&&&
I've tried placing the nested while loop inside the for loop, but all it does is an infinite loop :confused:
#include <iostream>
using namespace std;
int main()
{
int n, i, j;
do{
cout <<" Enter a positive int n: ";
cin >> n;
cout << endl;
} while (n < 0 && n > 10);
do{
for (i = 1; i <= n; i++)
{
for (j = 1; j <= i; j++)
cout << "*\t";
cout << endl;
}
} while (i <= n);
}
Thank you for your help :)