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