Write a program to print all the perfect squares in the given range. Spaces between the numbers are important and they should be in one line. Use System.out.println or System.out.print for printing.
Input (Range) | Printed Output |
---|---|
50 to 125 |
64 81 100 121 |
1 to 125 |
1 4 9 16 25 36 49 64 81 100 121 |
5000 to 5900 |
5041 5184 5329 5476 5625 5776 |
class PrintPerfectSquaresInTheGivenRange
{ public static void main(String s[])
{
int start = 50;
int end = 125;
printPerfectSquares(start, end);
}
public static void printPerfectSquares(int start, int end)
{
//Write code here to print the perfect squares in the given range.
}
}
Topic: Nested for Loop In Java