Tuesday, 8 April 2014

c program for given number is palindrome or not

#include<stdio.h>
#include<string.h>
int main()
{
int number,i,count=0;
char string1[10],string2[10];

printf("nEnter a number:");
scanf("%d",&number);

sprintf(string1,"%d",number); // Converting Number to String

strcpy(string2,string1); // Copy String into Other
strrev(string2); // Reverse 2nd Number

count = strcmp(string1,string2);

if(count==0)
     printf("%d is a prime number",number);
else
     printf("%d is not a prime number",number);
return 0;
}

No comments:

Post a Comment