Written by Sai Sandeep Thota on February 27, 2014 in Java > Programming

Java Program to Print Name in Right angled Triangle

GET ALERTS:

Get our Latest updates delivered to your mailbox!

In this article we are using a for loop to print the Name in the form of a right angled Triangle.
Download Source Code

Java Program to Print Name in Right angled Triangle

import java.util.Scanner;

class printNameTriangle {
	public static void main(String args[]) {
		String name, tri="";
		Scanner get = new Scanner(System.in);
		System.out.print("Enter a Name: ");
		name = get.nextLine();
		System.out.println();
		for(int i=0;i<name.length();i++) {
				tri = tri + name.charAt(i);
				System.out.println(tri);
		}
	}
}

Output:
Print_Name_Triangle_Java

{ 0 comments… add one now }

Leave a Comment

Previous post:

Next post: