Palindrome:
A
palindromic number is a number that remains the same when its digits are
reversed. Like 151, for example, it is "symmetrical". The
term palindromic is derived from palindrome, which refers to a word (such as
rotor or racecar) whose spelling is unchanged when its letters are reversed
for example
Declare @num int=321,@rm int, @temp varchar(50)='',@a int
set @a=@num
while(@num>=1)
begin
set @rm=@num%10
set @num=@num/10
set @temp=+@temp+cast(@rm as varchar)
end
if(@a=@temp)
begin
select 'The Input Number
'+cast(@a as varchar)+' is a palindrome' 'Number'
end
else
begin
select 'The Input Number
'+cast(@a as varchar)+' is not a palindrome' 'Number'
end
Output:
The Input Number 321 is not a palindrome
No comments :
Post a Comment