Java Program to Display Square Numbers

In this program, you'll learn to display Square numbers between two given intervals, low and high. You'll learn to do this using a while loop in Java.The while statement is used to repeat a block of statements while some condition is true. The condition must become false somewhere in the loop, otherwise it will never terminate.

Purpose - to repeat statements The purpose of the while statement is to repeat a group of Java statements many times. It's written just like an if statement, except that it uses the while keyword.

General Form :
The while statement has this form :

 while (condition) {
    ...statements to repeat while the condition is true 
} 


Condition is true or false The value of condition must be true or false (ie, a boolean value). It is often a comparison (see example below).

Loop continues while the condition is true ,Print square numbers between 1 to 10


When you run the program, the output will be:

1 4 9 16 25 36 49 64 81 100 

Previous Post Next Post