Write a do- while( ) loop to print the natural numbers from 1 to 15.
Share
Write a do- while( ) loop to print the natural numbers from 1 to 15.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Answer:
int i = 1;
do
{
System.out.println(i);
i += 1;
}while(i<=15);
Explanation:
variable i is stored with the natural number to be printed.
When it comes inside the it gets printed and then gets incremented. Then the condition is checked. If the condition evaluates to true then the loop continues else it is terminated.
(I use the BlueJ environment)
Mark it as the brainliest , if you find it helpful.