Check a String for Palindrome

Program:


    #include<iostream.h>
    #include<conio.h>
    #include<string.h>
    #define size 80
void main() { char string[size]; int length,mid,i=0; clrscr(); cout<<"\nEnter a string of length < "<<size<<"\n\n"; cin.getline(string,80); length=strlen(string); mid=length/2; while(i<mid) if(string[i]!=string[length-1-i]) break; else i++; } if(i==mid) cout<<"\nString is Palindrome"; else cout<<"\nString is not Palindrome"; getch(); }
Powered by nasrullah.in - TechnoNasr 2003-2020.
Designed & Developed by Mohamed Nasrullah.M