About Me

My photo
Raipur, Chhattisgarh, India
Hi , I am Amit Thakur. I have worked as a QA Engineer for two years and as a Java Developer for one year in NIHILENT TECHNOLOGIES PVT. LTD., Pune.Currently I am working as DEAN (Research & Development) in Bhilai Institute of Technology, Raipur.

Monday, September 2, 2013

Check Whether Given Number is Palindrome or Not ????

#include<stdio.h>
#include<string.h>
int main()
{
int num,i,count=0;
char str1[10],str2[10];

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

sprintf(str1,"%d",num); // Convert Number to String

strcpy(str2,str1); // Copy String into Other
strrev(str2); // Reverse 2nd Number

count = strcmp(str1,str2);

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

No comments: