Thursday, August 21, 2014

Java Program To Print The Pattern 1,11,111,1111,....n


In this program we will print the pattern 1,11,111,1111,....n

import java.io.*;

class P
{
 int i,j,n;
 BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
 void show() throws Exception
 {
      System.out.println("\nEnter the value of 'n':");
      n=Integer.parseInt(br.readLine());
      for(i=0;i< n;i++)      {
           for(j=0;j<=i;j++)
           {
                System.out.print("1");
            }
            if(i!=n-1)
            System.out.print(",");
        }
    }
    public static void main(String args[])throws Exception
    {
      P ob=new P();
         ob.show();
        }
    }



Related PostBlueJ Programs On Pattern

No comments:

Post a Comment

Subscribe via email

Enter your email address:

Delivered by FeedBurner