import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class DoWhileExample
{
public static void main(String args[]) throws IOException
{
int n,i=1;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//initialize
System.out.println("Enter number of lines you want to display?");
n=Integer.valueOf(br.readLine()).intValue();
do
import java.io.IOException;
import java.io.InputStreamReader;
public class DoWhileExample
{
public static void main(String args[]) throws IOException
{
int n,i=1;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//initialize
System.out.println("Enter number of lines you want to display?");
n=Integer.valueOf(br.readLine()).intValue();
do
{
for(int j=0;j {
System.out.print(i);
System.out.print(" ");
}
System.out.println("\n");
//increment
i++;
} while(i<=n); //condition
}
}
Output =>
Enter number of lines you want to display?
10
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
6 6 6 6 6 6
7 7 7 7 7 7 7
8 8 8 8 8 8 8 8
9 9 9 9 9 9 9 9 9
10 10 10 10 10 10 10 10 10 10
for(int j=0;j {
System.out.print(i);
System.out.print(" ");
}
System.out.println("\n");
//increment
i++;
} while(i<=n); //condition
}
}
Output =>
Enter number of lines you want to display?
10
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
6 6 6 6 6 6
7 7 7 7 7 7 7
8 8 8 8 8 8 8 8
9 9 9 9 9 9 9 9 9
10 10 10 10 10 10 10 10 10 10
No comments:
Post a Comment