Wednesday, 9 October 2013

Program for Pattern

//Program for Pattern
//Developed by Ahlam Ansari


import java.io.*;
import java.util.*;
class ptrn
{
    public static void main(String ahlam[])
    {
        int m;
        System.out.println("Enter the number of rows");
        Scanner sc=new Scanner(System.in);
        Scanner n=new Scanner(System.in);
        m=sc.nextInt();
        //n=nextInt();
        for(int i=0;i<m;i++)
        {
            for(int j=0;j<m-i;j++)
            {
                System.out.print("*");
            }
            System.out.print("\n");
        }
    }
}


/*
C:\Users\Ahlam\Google Drive\My Lectures\Fall\OOPM\Programs>javac ptrn.java

C:\Users\Ahlam\Google Drive\My Lectures\Fall\OOPM\Programs>java ptrn
Enter the number of rows
5
*****
****
***
**
*

C:\Users\Ahlam\Google Drive\My Lectures\Fall\OOPM\Programs>
*/

No comments:

Post a Comment