How to palindrom string in c language?

Answers were Sorted based on User's Feedback



How to palindrom string in c language?..

Answer / swati chouksey

1st one of program is for Armstrong number not for
palindrom.......

Is This Answer Correct ?    5 Yes 0 No

How to palindrom string in c language?..

Answer / roxy

#include<stdio.h>
#include<string.h>

main()
{
char p1[20], p2[20];

char pal;

clrscr();

printf("Enter a word: ");
gets(p1);

strcpy(p2,p1);
strrev(p1);

if(strcmp(p2,p1)==0)
{
printf("\nIt is a palindrome");
}
else
printf("\nNot a Palindrome");

getch();
}

Is This Answer Correct ?    5 Yes 0 No

How to palindrom string in c language?..

Answer / sreejesh1987

#include<stdio.h>
#include<conio.h>
void main()
{
char str[20];
int i,l,n,f=0;
clrscr();
printf("enter string: ");//malayalam
scanf("%s",str);
l=strlen(str)-1;//9-1=8
n=l/2+1;//5
for(i=0;i<n;i++)
if(strcmp(str[i],str[l-i])!=0)//0=m,8-0=m//1=a,8-1=a
f=1;
if(f)
printf("\nNot a palindrome");
else
printf("\nIt is a palindrome");

getch();
}

Is This Answer Correct ?    2 Yes 0 No

How to palindrom string in c language?..

Answer / govind verma

#include<stdio.h>
#include<string.h>

int main()
{
char ch[100];
int len;
printf("enter any string:\n");
gets(ch);
len=strlen(ch);
int i;
int flag=0;
for(i=0;i<=len/2;i++)
{
if(ch[i]==ch[len-1-i])
flag=1;
else
{
flag=0;
break;
}
}
if(flag)
printf("entered string is pallendrom ");
else
printf("entered string is not pallendrom ");


return 0;
}

Is This Answer Correct ?    0 Yes 0 No

How to palindrom string in c language?..

Answer / sandeep

#include<stdio.h>
#include<conio.h>
void main()
{
char n[6];
int i,l;
clrscr();
printf("enter string");
scanf("%s",n);
l=strlen(n);
if((l%2)==0)
exit(0);//length of string is even and cant be a palindrome
for(i=1;i<l/2;i++)
{
if(n[i]==n([l/2+i)])
i++;
else
printf("string is not palindrome");
}
getch();
}

Is This Answer Correct ?    3 Yes 7 No

How to palindrom string in c language?..

Answer / manish kumar

#include<stdio.h>
#include<conio.h>
void main()
{
int n,a,b,c;
printf("enter a no.");
scanf("%d",&n);

c=n%10;
n=n/10;

b=n%10;
a=n/10;

if((a*a*a)+(b*b*b)+(c*c*c)==n)
{

printf("entered no. by you is a palindrom no.");
printf("%d",n);

else

printf("enter any button to exit............");
}
getch();
}

Is This Answer Correct ?    2 Yes 11 No

Post New Answer

More C Code Interview Questions

1) int i=5; j=i++ + i++ + i++; printf("%d",j);This code gives the answer 15.But if we replace the value of the j then anser is different?why? 2)int i=5; printf("%d",i++ + i++ + i++); this givs 18.

8 Answers   IBPS, Infosys, TCS,


which function is used to clear the buffer stream on gcc? for example: I wrote following code on gcc #include<stdio.h> int main(void) { char ch; int a,b; printf("\nenter two numbers:\t"); scanf("%d%d",&a,&b); printf("enter number is %d and %d",a,b); printf("\nentercharacter:\t"); scanf("%c",&ch); printf("enter character is %c",ch); return 0; } in above progarm ch could not be scan. why?plz tell me solution.

2 Answers  


main() { extern int i; i=20; printf("%d",i); }

1 Answers   Value Labs,


Find the largest number in a binary tree

7 Answers   Infosys,


what is the output of the below program & why ? #include<stdio.h> void main() { int a=10,b=20,c=30; printf("%d",scanf("%d%d%d",&a,&b,&c)); }

6 Answers   CSC, IIIT,






main() { char *p = “ayqm”; printf(“%c”,++*(p++)); }

29 Answers   IBM, TCS, UGC NET, Wipro,


#include<stdio.h> int main() { int x=2,y; y=++x*x++*++x; printf("%d",y); } Output for this program is 64. can you explain how this output is come??

1 Answers  


How we will connect multiple client ? (without using fork,thread)

3 Answers   TelDNA,


int main() { int x=10; printf("x=%d, count of earlier print=%d", x,printf("x=%d, y=%d",x,--x)); getch(); } ================================================== returns error>> ld returned 1 exit status =================================================== Does it have something to do with printf() inside another printf().

2 Answers  


Write a procedure to implement highlight as a blinking operation

2 Answers  


could you please send the program code for multiplying sparse matrix in c????

0 Answers  


main() { extern out; printf("%d", out); } int out=100;

1 Answers  


Categories