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
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:
- START
- Initialise a variable with value = 1
- Display the value of the variable.
- Increment the value of the variable by 1.
- Repeat this steps till the number is less than or equal to 11.
- STOP
Refer to the attachment for output ☑.
Attachments:
Similar questions