Computer Science, asked by jayaramjayaraman6251, 4 months ago

Write the Java program to print the natural numbers from 1 to 15 using the

while loop.​

Answers

Answered by rishabhshah2609
2

Answer:

Explanation:

public class Test

{

void prnNaturalNos( )

{

int i = 1 ;

for (i= 1 ; i < = 15 ; i++)

System.out.print( i ) ;

}

}

Output Produced is:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

The For loop:

The for loop is the easiest to understand of the Java loops.

All its loop-control elements are gathered in one place (on the top of the loop) , while in the other loop construction of Java, they (top-control elements) are scattered about the program.

Similar questions