Help with Paralillelogram

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?.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
  #include <iostream>
using namespace 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.";
	}

	 else if (r >= 23)

		{
			cout << "That is too many rows for me to make a parallelogram.";
		}

        else if (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 << " ";
					 	}
						else if  (j>=k)
						{
					 		cout << "*";
						}
					}
					
				for (int o=0; o < r-1; o++)
				{
					 	if (o <= m) 
						{
	 		  	  	  		cout << " ";
					 	}
						else if (o >=m)
						{
							cout << "*";
						}
				}
				cout << endl; 
				}

return 0;

}
Topic archived. No new replies allowed.