Do While Loop in Java.
100% Working Code and Projects.
if you need any help about project and Application Contact Shelly at:+917888361589.
Java Code Below :-
package CodingStartupAbheer;
import java.util.Scanner;
public class DoWhile {
public static void main (String Abheer[])
{
Scanner a= new Scanner(System.in);
System.out.println("Enter your name");
String c= a.nextLine();
System.out.println("How many times you want to print your name");
int b=a.nextInt();
int i=1;
do
{
System.out.println(c);
i++;
}while(i<=b);
}
}
Output:-
Enter your name
Coding Startup
How many times you want to print your name
3
Coding Startup
Coding Startup
Coding Startup
Explanation:-
This is a first loop which was invented. In this loop, first it will execute the main part that have to be executed then it will check the condition. In this once the statement or that part will be executed whether the condition is true ore not. if the condition is true then it will work properly.
0 Comments:
Post a Comment