Right side triangle

Draw right side elevated triangle in php, problem 3

You need to draw a right side staircase structure i.e. right side triangle structue . It seems to stand as right angle triangle from right side.

 

Input

Input is given integer N,consider it the height of staircase


Output


Print right side staircase with symbol '*' and spaces.



Solution


<?php

$n=6;

 

for($i=1;$i<=$n;$i++) {

 for($j=$n;$j>=1;$j--) {

  if($j>$i) {

   echo ' ';

  }

  else {

   echo '*';

  }

  if($j==1) {

   //echo PHP_EOL;

   echo '\n\r'

  }

 }

}

?>

NOTE:Browser does not show blank space before any character. See view source to see actual result

Put any digit in place of ' ', to understand process

Name
Email
Comments
Back
Funding

We need your support to operate it properly. We have lots of ideas but less fund, so help us with your funding.

Thoughts of the day

Success is not built on success. It's built on failure. It's built on frustration. Sometimes its built on catastrophe.

Sumner Redstone
Sell your product online

Do you want to sell products online with no extra cost?

Send your details, our executive will contact you

Email:

Mobile:

Location:

Polls
Which device you use most for facebook application?
Laptop/PC
15%

 


Android
49%

 


IOS
32%

 


Blackberry
4%

 


Tutorial On Request
Q. Ask us for any tutorial or any thing which helps to build your career better.
Email:
Query: