I need another nested while loop to print out '&' characters. I'm just not sure where to place it, as when I've tried, I only get infinite loops of '&' characters printed out.
#include <cstdlib>
#include <iostream>
#include <string>
usingnamespace std;
int main(int argc, char *argv[])
{
int l,w,h, input, width, width2, recwidth, twidth2, twidth, twidth3;
string character;
cout << "what shape do you want to create" << endl;
cout << "1) square 2) Rectangle 3) Triangle " << endl;
cin >> input;
if (input == 1)
{ cout << "OK. I am ready. What is the side length" << endl;
cin >> l ;
cout << "what character do you want to use????" << endl;
cin >> character;
system ("CLS");
for (int width=1; width <= l; width++)
{
for (int width2=1 ; width2 <=l; width2++)
{
cout << character ;
}
cout << endl;
}
}
elseif (input ==2)
{
cout << "OK. I am ready. What is the side length" << endl;
cin >> l ;
cout << "OK. I am ready. what is the width?" << endl;
cin >> recwidth ;
cout << "what character do you want to use????" << endl;
cin >> character;
system ("CLS");
for (int width=1; width <= l; width++)
{
for (int width2=1 ; width2 <=recwidth; width2++)
{
cout << character ;
}
cout << endl;
}
}
elseif (input ==3)
{
cout << "OK. I am ready. What is the side length" << endl;
cin >> l ;
cout << " what is the second side?" << endl;
cin >> twidth2 ;
cout << "what character do you want to use????" << endl;
cin >> character;
system ("CLS");
for (int width=1; width <= l; width++)
{
for (int width2 = width -1 ; width2 < twidth2; width2--)
{
cout << character ;
cout << endl;
}
cout << endl;
}
}
{
cout << " " << endl;
}
system("PAUSE");
return EXIT_SUCCESS;
}
int n, i;
int j, k;
do{
cout <<" Enter a positive int n: ";
cin >> n;
cout << endl;
} while (n < 0 || n > 10);// better if you change it to OR
do{
for (i = 1; i <= n; i++)
{
for (j = 1; j <= i; j++)
{
cout << "*\t";
}
cout << endl;
for (j = 1; j <= i; j++)
{
cout << "&\t";
}
cout << endl;
}
} while (i <= n);
return 0;
}