Parallelogram is suppose to be between 3 and 23 lines forced to enter a value between
3 and 23. I suppose to use only 3 loops. i have used more than that and got it working
but i could not get working with only 3 loops.When i run this program it creates a Parallelogram
but the side which should go down is going on the right side. How can i fix it?.
#include <iostream>
usingnamespace std;
int main ()
{
int r = 0;
cout << "Enter number of rows: ";
cin >> r;
if (r <=3)
{
cout << "That is too few rows for me to make a parallelogram.";
}
elseif (r >= 23)
{
cout << "That is too many rows for me to make a parallelogram.";
}
elseif (r%2==0)
r = r+1;
r = r/2 + 1;
for (int i=0, k = r-2, l=0, m = r-1; i < r || l < r-1 ; i++,k--,l++, m--)
{
for (int j=0; j < r; j++)
{
if(j <= k)
{
cout << " ";
}
elseif (j>=k)
{
cout << "*";
}
}
for (int o=0; o < r-1; o++)
{
if (o <= m)
{
cout << " ";
}
elseif (o >=m)
{
cout << "*";
}
}
cout << endl;
}
return 0;
}