In mathematics, a square number or perfect square is an integer that is the square of an integer. In other words, it is the product of some integer with itself. For example, 9 is a square number, since it equals 3^{2 } and can be written as 3 × 3.

In QBASIC to find the square number is very easy. Because we have a mathematicl library function called SQR. Lets see the program to print the kperfect square numbers from 1 to 100.

```
CLS
FOR i = 1 TO 100
n = SQR(i)
IF n = INT(n) THEN
PRINT n * n;
END IF
NEXT i
END
```

**Output**

```
1 4 9 16 25 36 49 64 81 100
```

Using **SUB ... END SUB**

```
DECLARE SUB square()
CLS
CALL square
END
SUB square ()
FOR i = 1 TO 100
n = SQR(i)
IF n = INT(n) THEN
PRINT n * n;
END IF
NEXT i
END SUB
```

Using **Function ... END FUNCTION**

```
DECLARE FUNCTION square()
CLS
sq = square
END
FUNCTION square ()
FOR i = 1 TO 100
n = SQR(i)
IF n = INT(n) THEN
PRINT n * n;
END IF
NEXT i
END FUNCTION
```

3177