#include<stdio.h> #include<conio.h> int stpal(char str[50]); void main() { char str[50]; int pal; clrscr(); printf(“nnt ENTER A STRING…: “); gets(str); pal = stpal(str); if(pal) printf(“nt THE ENTERED STRING IS A PALINDROME”); else printf(“nt THE ENTERED STRING IS NOT A PALINDROME”); getch(); } int stpal(char str[50]) { int i = 0, len = 0, pal = 1; while(str[len]!=’′) len++; len–; for(i=0; i<len/2; i++) { if(str[i] == str[len-i]) pal = 1; else { pal = 0; break; } } return pal; }
|
No comments:
Post a Comment