Friday 1 May 2015

Print the mirror image of right angle triangle from the right side using number

package star;

import java.util.Scanner;

public class num4 {

public static void main(String[] args) {
int n, c, d,e;
     Scanner in = new Scanner(System.in);

     System.out.println("Enter the number of rows of triangle you want");
     n = in.nextInt();

     System.out.println("Triangle :-");

     for(c=1;c<=n;c++)
   {
      for(d=1;d<c;d++)
      {
          System.out.print(" ");
      }
      for(e=1;e<=n+1-c;e++)
      {
          System.out.print(""+e);
      }
      System.out.print("\n");
   }
   }


}

No comments:

Post a Comment