Posted by: Sourav | December 6, 2013

Palindrome check in qBasic


CLS

DIM word AS STRING

DIM reverse AS STRING

DIM x AS INTEGER

 

reverse = “”

INPUT “Enter word “, word

FOR x = LEN(word) TO 1 STEP -1

reverse = reverse + MID$(word, x, 1)

NEXT x

IF UCASE$(word) = UCASE$(reverse) THEN

PRINT “Palindrome”

ELSE

PRINT “Not”

END IF

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: