I have to write a program which prints all squares less than a value of n. I have this:
My problem is the output includes 100. Where did I go wrong? Is this just a fluke because 100 happens to be a perfect square? Is there anyway to fix it?Code:int n = 0; int x = 0; while (x < 100) { x = n*n; System.out.print(x + " "); n = (n + 1); }
Bookmarks