Computer Science, asked by Anonymous, 3 months ago

Write a QBASIC program to check the given number is Palindrome or not. ​

Answers

Answered by Anonymous
2

Explanation:

Let num be the input number.

Set flag = 1

Convert num to string and compare ith character from the start and ith character from last using a loop. If any pair of ith character from the start and ith character from the end are not equal then it means that the number is not a palindrome, set flag = 0.

If the flag is equal to 0 then the input number is not a palindrome. If the flag is not equal to 0 then the input is a palindrome.

QBasic Check if number is Palindrome using for loop

CLS

INPUT "Enter a Number: ", num

'Convert Number to String

num$ = STR$(num)

'flag variable

flag = 1

'Length of input number

n = LEN(num$)

' i: ith number from start

' n-i+1 ith number from last

FOR i = 1 TO n

IF MID$(num$, i, 1) <> MID$(num$, n - i + 1, 1) THEN

flag = 0

END IF

NEXT i

IF flag = 0 THEN

PRINT "NOT PALINDROME";

ELSE

PRINT "PALINDROME";

END IF

END

ok

Attachments:
Answered by khushbu0812200
4

Answer:

sister yeh appny gali gussy mein likhi hai fir mazak mein

Similar questions