palindrome for strings and numbers----Can anybody do the
prog?

Answers were Sorted based on User's Feedback



palindrome for strings and numbers----Can anybody do the prog?..

Answer / harish

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char a[20],b[20];
int i;
clrscr();
printf("\n Enter the Number or String to find Palindrome");
scanf("%s",a);
strcpy(b,a);
strrev(a);
if(strcmp(a,b)==0)
{
printf("\n Entered data is Palindrome\n");
}
else
{
printf("\n Entered data is not a Palindrome\n");
}
getch();
}

Is This Answer Correct ?    9 Yes 2 No

palindrome for strings and numbers----Can anybody do the prog?..

Answer / subbu

/*some corrections to above solution*/
#include<stdio.h>
#include<conio.h>
void main()
{
int n,r,temp;
int s=0;

printf("enter the number");
scanf("%d",&n);
temp=n;
while(temp>0)
{
r=temp%10;
s=s*10+r;
temp=temp/10;
}
if(n==s)
printf("number is pallindrome");
else
printf("not pallindrome");
getch();
}

Is This Answer Correct ?    10 Yes 5 No

palindrome for strings and numbers----Can anybody do the prog?..

Answer / dally

#include<stdio.h>
int main()
{
int n,sum=0,temp;
printf("Enter nuber\n");
scanf("%d",&n);
temp = n;
while(n>1)
{
n = n%10;
sum = n + sum*10;
n = n / 10;
}
if(temp == sum)
printf("Given number is polindram\n");
else
printf("Given number is not polindram\n");

}

Is This Answer Correct ?    4 Yes 2 No

palindrome for strings and numbers----Can anybody do the prog?..

Answer / arup bhattacharya

#include<stdio.h>
#include<conio.h>
void main()
{
int n,r,temp;
int s=0;
clrscr();
printf("enter the number");
scanf("%d",&n);
temp=n;
while(temp>0)
{
r=temp%10;
s=s*10+r;
temp=temp/10;
}
if(n==temp)
printf(number is pallindrome");
else
printf("not pallindrome");
getch();
}

Is This Answer Correct ?    9 Yes 8 No

palindrome for strings and numbers----Can anybody do the prog?..

Answer / shruti

//the palindrome for string can also be written as below,
without using inbuilt functions.

void main()
{
char str[10];
int flag = 0;
int i , j;

puts("ENTER THE STRING");
fflush(stdin);
gets(str);


for(i = 0 ; str[i] != '\0' ; i++);
i--;

for(j = 0 ; j<i ; j++ , i--)
{
if(str[j] == str[i])
flag = 1;
else
{
flag = 0;
break;
}
}

if(flag == 1)
puts("STRING IS A PALINDROME");
else
puts("STRING IS NOT A PALINDROME");
}

Is This Answer Correct ?    4 Yes 3 No

palindrome for strings and numbers----Can anybody do the prog?..

Answer / sree

#include<stdio.h>
void main
{
int n,t,d,r;
printf("Enter the number:");
scanf("%d",&n);
t=n;
while(n>=1)
{
d=n%10;
r=(r*10)+d;
n=n/10;
}
if(t==r)
printf("Palindrome");
else
printf("Not a palindrome");
}

Is This Answer Correct ?    3 Yes 3 No

Post New Answer

More C Interview Questions

What is far pointer in c?

0 Answers  


Can you return null in c?

0 Answers  


number 2 plssssss help !!....using array.. turbo c.. create a program that will accept a number and determine if it is a happy number or an unhappy number.. example: enter a number : 7 7*7=49 then 4 and 9 4*4 and 9*9== 16 + 18 gives you 97 then 9 and 7 9*9 and 7*7 == 81 + 49 gives you 130 then 1 and 3 1*1 and 3*3 == 1 + 9 gives you 10 1*1 gives you 1 sample output: 7= 49= 16+81= 97= 81+49=130 =1+9=10 =1 "7 is a happy number" . if the last number is 2 then the number being inputed is not a happy number.

3 Answers  


What are global variables and explain how do you declare them?

0 Answers  


write a program that finds the factorial of a number using recursion?

13 Answers   Infosys, TATA,






There are 3 baskets of fruits with worng lables,one basket has apple,another basket has orange,another has combination of apple and orange,what is the least way of interchange the lables.

15 Answers   Cisco, Google, MBT,


What are static variables in c?

0 Answers  


void main() { char c; while(c=getchar()!='\n') printf("%d",c); } o/p=11 why?

8 Answers   Wipro,


What is variable initialization and why is it important?

0 Answers  


what is c language?

2 Answers  


What is the explanation for modular programming?

0 Answers  


application of static variables in real time

1 Answers   Bosch,


Categories