Thursday, 23 June 2016

Program to print a Star Pattern Type-6.

Explanation :
If n=6 then output will be
 *
 *  *
 *  *  *
 *  *  *  *
 *  *  *  *  *
 *  *  *  *  *  * .

Code:

import java.util.Scanner;
public class StarPattern6
{
    public static void main( String args[])
    {
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter the no. of lines: ");
        int line=sc.nextInt();
     
        int i,j,k,t=0;
        for (i=0; i<line; i++)
        {
            for (j=0; j<=i; j++)
            {
                System.out.printf(" * ");
            }
            System.out.printf("\n");
        }
    }
}

No comments:

Post a Comment