Wednesday 29 April 2015

Print the mirror image of right angle triangle using number

package star;

import java.util.Scanner;

public class num3 {

public static void main(String[] args) {
int n, c, d;
     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<=n+1-c;d++)
           {
               System.out.print(""+d);
           }
           System.out.print("\n");
       }
   }

}

No comments:

Post a Comment