Printing 1 to 10 using do while loop
PROGRAM
import java.util.*;
class dowhile1to10
{
public static void main()
{
int a,b;
Scanner sc=new Scanner(System.in);
System.out.print("Enter initial number : ");
a=sc.nextInt();
System.out.print("Enter upto you Final number : ");
b=sc.nextInt();
do {
System.out.println(a);
a++;
}
while(a<=b);
}
}
OUTPUT
0 Comments