Vous êtes sur la page 1sur 1

#include <stdio.

h>
#include <string.h>
int main() {
char one[200] = "madam";
char two[200];
strcpy(two, one);
strrev(two);
if(strcmp(one, two) == 0)
printf("The entered string %s is a palindrome.\n", one);
else
printf("The entered string %s is not a palindrome.\n",
one);
printf("The reverse of the string is %s.\n", two);
return 0;
}

ANOTHER SIMPLE PROGRAM:


#include<stdio.h>
main()
{
char a[20],b[20];
printf("enter a string");
scanf("%s",&a);
strcpy(b,a);//copies string a to b
strrev(b);//reverses string b
if(strcmp(a,b)==0)//compares if the original and reverse strings are same
printf("\n%s is a palindrome",a);
else
printf("\n%s is not a palindrome",a);
return 0;
}

Vous aimerez peut-être aussi