The do-while loop always executes its body at least once, because its conditional expression is at the bottom of the loop.The do-while loop first executes the body of the loop and then evaluates the conditional expression. If this expression is true, the loop will repeat. Otherwise, the loop terminates.
Syntax:
do
{
// body of loop;
// Increment (or) Decrement;
} while(Condition) ;
import java.util.Scanner; public class do_while { public static void main(String args[]) { System.out.println("Enter The Limit : "); Scanner in =new Scanner(System.in); int n=in.nextInt(); int i=2; do { System.out.println(i); i=i+2; }while (i<=n); } }
Enter The Limit : 20 2 4 6 8 10 12 14 16 18 20To download raw file Click Here
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions