Nested Controlled structures problem

say
a= 6
b= 8
c=10


1
2
3
4
5
6
7
8
9
10
if (pow(c,2) == pow(a,2)+pow(b,2))
	{
	   cout << " Your triangle is a right triangle"<< endl;
	   for ( i = a; i <= c; i++)
		{
			for ( j =1  ; j<=b; j++)
			    cout <<"|0|";
			    cout << endl;
	        }
	}



When i run the code i get
|0||0||0||0||0||0||0||0|
|0||0||0||0||0||0||0||0|
|0||0||0||0||0||0||0||0|
|0||0||0||0||0||0||0||0|
|0||0||0||0||0||0||0||0|

instead of

|0||0||0||0||0||0||0||0|
|0||0||0||0||0||0||0||0|
|0||0||0||0||0||0||0||0|
|0||0||0||0||0||0||0||0|
|0||0||0||0||0||0||0||0|
|0||0||0||0||0||0||0||0| <<<<<<< Im missing this row
What should i change?

a= column
b= row
Last edited on
I'm failing to see how c is relevant to the format of the output.

Shouldn't line 4 be:

for ( i=0 ; i< a ; ++i )

or to match the inner loop:

for ( i=1; i<=a; ++i )
I see that you have c - a + 1 rows and b columns.
Im calculating the area of a triangle so if the user calculates the lengths of a right triangle my code recognizes it and creates that structure.

This helped me
for ( i=0 ; i< a ; ++i )
I can correctly see the output of lengths a,b
3,4
6,8


If i used

for ( i=1; i<=a; ++i )

it would be the same.( rows missing)
This code only correctly outputs
3,4


Thank You
Last edited on
Topic archived. No new replies allowed.