The following program asks the user to repeatedly enter an input
until the input is a perfect square (e.g., 0, 1, 4, 9, 16, 25,
etc.):
var b, i, x, n;
b = ??? ;
while (b==0){
x = prompt("Enter an integer that is a perfect
square");
n = Number(x);
for (i=0; i*i<=n; i++)
if (i*i==n)
b = 1;
}
What should be set as the initial value of b (in place of ???)
to make the program to work as the specified requirement?
The following program asks the user to repeatedly enter an input until the input is a perfect square (e.g., 0, 1, 4, 9,
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am