Please help me with star patterns or anything with a patterns like 'x' in C++. What ois the logic behind it.

x x ********
xx xx *******
xxx xxx *****
xxxx xxxx ***
xxxxx xxxxx **

these might look easy, but i dont get the logic. please give detailed explanation, with simple example, if you can;)

Try some code.

Here is a simple pseudo-code which represents the logic of the problem; no guarantees are given as to it's correctness.

for x in range(0, 10):
	for y in range(0, 10):
		if x >= y:
			print("X", end='')
			print("*", end='')

(OK, so it isn't so pseudo a code, but it should be clear enough, I think. It also doesn't exactly match the described results, but it is close enough to give the OP a head start.)

Edited 5 Years Ago by Schol-R-LEA: n/a

You will need two for loops ..... one is for row and the other is for column.Try something to put some effort on creating logic.

For the sample one....
the logic is...

for(i=1;i<=5;i++)//for 5 lines
for(j=1;j<i;j++)//for printing the x

Now you have to try your actual problem.
It your task. Please give some effort on logic making.
Thank you.

Try some code yourself.Anuradha Mandal is right.The logic is same as the pyramid printing. Try something .Then we will discuss more.

This article has been dead for over six months. Start a new discussion instead.