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();
}
}
No comments:
Post a Comment