Computer Science, asked by rishavkr63, 2 months ago

IF ANYBODY TELLS THE CORRECT ANSWER I WILL MARK YOU AS BRAINLIEST
(WRITE A PROGRAM IN DO WHILE LOOP JAVA TO DISPLAY 10 NATURAL NUMBERS)​

Answers

Answered by anindyaadhikari13
1

Required Answer:-

Correct Question:

  • Write a Java program using do while loop to display first 10 natural numbers.

Solution:

Here comes the program.

public class Number {

 public static void main(String[] args) {

    int i=1;

    do {

       System.out.print(i+" ");

       i=i+1;

    } while (i<=10);

 }

}

Algorithm:

  1. START
  2. Initialise a variable with value = 1
  3. Display the value of the variable.
  4. Increment the value of the variable by 1.
  5. Repeat this steps till the number is less than or equal to 11.
  6. STOP

Refer to the attachment for output ☑.

Attachments:
Similar questions