Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Program to check if a string is palindrome.
- #include<iostream.h>
- #include<conio.h>
- #include<string.h>
- #include<stdio.h>
- void main()
- {
- clrscr();
- char a[80];
- int z=1;
- cout<<"Enter a string: ";
- gets(a);
- int n=strlen(a);
- for(int i=0,j=n-1;i<=(n-1)/2;i++,j--)
- {
- if(a[i]!=a[j])
- {
- z=0;
- break;
- }
- }
- if(z==0)
- cout<<"The string is not palindrome.";
- else
- cout<<"The string is palinrome.";
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment