Mix (C++ and Assembly) Program to Check if String is Palindrome or not

#include<iostream.h>
#include<conio.h>
void main()
{
int nos[5],x,y;
cout<<"\n Enter 5 numbers:";
int i,j;
for(i=0;i<5;i++)
{
cin>>nos[i];
}
for(i=0,j=4;i<3;i++,j--)
{
x=nos[i];
y=nos[j];
_asm{
mov ax,x
mov bx,y
cmp ax,bx
jnz no
}
}
cout<<"\n Array is Palindrome.";
goto end;
no:
cout<<"\n Array is not palindrome.";
end:
getch();
}
/* Output
 Enter 5 numbers:10
12
15
12
10
 Array is Palindrome.
 Enter 5 numbers:10
12
15
10
12
 Array is not palindrome.
*/

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.