Computer for SEE and NEB

It is a complete SEE and NEB solution for computer science. It includes Computer Fundamentals, Database (SQL), Programming in C QBASIC, CSS, JavaScript, and PHP for beginners.

Breaking

Post Top Ad

Your Ad Spot

Wednesday, December 7, 2022

QBASIC program to check whether the input digit is palindrome or not

 QBASIC program to check whether the input digit is palindrome or not


CLS

INPUT "Enter any digit:"; d

n = d

WHILE d > 0

r = d MOD 10

s = s * 10 + r

d = INT(d / 10)

WEND

IF n = s THEN

PRINT n; "is palindrome digit"

ELSE

PRINT n; "is not palindrome digit"

END IF

END

 

Using SUB procedure (SUB….END SUB)

DECLARE SUB pal (d)

CLS

INPUT "Enter any digit:"; d

CALL pal(d)

END

 

SUB pal (d)

n = d

WHILE d > 0

r = d MOD 10

s = s * 10 + r

d = INT(d / 10)

WEND

IF n = s THEN

PRINT n; "is palindrome digit"

ELSE

PRINT n; "is not palindrome digit"

END IF

END SUB

 

Using FUNCTION procedure (FUNCTION…END FUNCTION)

DECLARE FUNCTION pal$ (d)

CLS

INPUT "Enter any digit:"; d

PRINT d; pal$(d)

END

 

FUNCTION pal$ (d)

 n = d

WHILE d > 0

r = d MOD 10

s = s * 10 + r

d = INT(d / 10)

WEND

IF n = s THEN

pal$ = "is palindrome digit"

ELSE

pal$ = "is not palindrome digit"

END IF

END FUNCTION


Output:



No comments:

Post a Comment

Post Top Ad

Your Ad Spot

Pages