DO WHILE LOOP IN JAVA

The Functionality of do while loop is close enough to while loop but the main difference is that do while loop check the statement after the execution.

Source Code 


package com.ancodingpoint.www;
import java.util.Scanner;
public class Loops{

 public static void main(String[] args) {
    Scanner input = new Scanner (System.in);
     int num [] = new int [5];
     int a =0;
     int b =0;
     do
     {
         System.out.println(" Enter Your Number......! ");
         num[a] = input.nextInt();
         a++;
     } 
     while (a<5);
     
  System.out.println(" Again Printing these Numbers with do-while Loop");
  do{
      System.out.println(num[b]);
      b++;
  }
  while (b<5);
     }
 }

Output of the Program





Share on Google Plus

About Asad

Asad Niazi is Software Engineer , Programmer, Web Developer and a young mentor of BloggersTown and PProgramming. Asad Love to writes about Technology, Programming, Blogging and make money online.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment