Monday, October 11, 2021

QBASIC program to Print the Perfect Square numbers from 1 to 100 (1, 4, 9, 16, 25, 36, 49, 64, 81, 100)

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 32 and can be written as 3 × 3.

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


Using SUB Procedure

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 Procedure

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

Source : School Tech

No comments:

Post a Comment

If you have any doubts, Please let me know.

[Download PDF] Computer Science Book Gread-10 in Nepali Language

 If you are searching for class 10 Computer Science in Nepali pdf for free download then you are at the right page. This book is soley publi...