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

#define assert(cond) if(!(cond)) \ (fprintf(stderr, "assertion failed: %s, file %s, line %d \n",#cond,\ __FILE__,__LINE__), abort()) void main() { int i = 10; if(i==0) assert(i < 100); else printf("This statement becomes else for if in assert macro"); }

1 Answers  


main() { int i=_l_abc(10); printf("%d\n",--i); } int _l_abc(int i) { return(i++); }

2 Answers  


main() { int i, n; char *x = “girl”; n = strlen(x); *x = x[n]; for(i=0; i<n; ++i) { printf(“%s\n”,x); x++; } }

2 Answers  


write a c-program to find gcd using recursive functions

5 Answers   HTC, Infotech,


Give a one-line C expression to test whether a number is a power of 2.

10 Answers   Microsoft,






Is the following statement a declaration/definition. Find what does it mean? int (*x)[10];

1 Answers  


void main() { int *i = 0x400; // i points to the address 400 *i = 0; // set the value of memory location pointed by i; }

2 Answers  


write a function to give demostrate the functionality of 3d in 1d. function prototye: change(int value,int indexX,int indexY,int indexZ, int [] 1dArray); value=what is the date; indexX=x-asix indexY=y-axis indexZ=z-axis and 1dArray=in which and where the value is stored??

0 Answers   Nagarro,


func(a,b) int a,b; { return( a= (a==b) ); } main() { int process(),func(); printf("The value of process is %d !\n ",process(func,3,6)); } process(pf,val1,val2) int (*pf) (); int val1,val2; { return((*pf) (val1,val2)); }

1 Answers   Satyam,


how many processes will gate created execution of -------- fork(); fork(); fork(); -------- Please Explain... Thanks in advance..!

8 Answers   GATE,


main() { int x=5; clrscr(); for(;x<= 0;x--) { printf("x=%d ", x--); } } a. 5, 3, 1 b. 5, 2, 1, c. 5, 3, 1, -1, 3 d. –3, -1, 1, 3, 5

2 Answers   HCL,


To Write a C program to remove the repeated characters in the entered expression or in entered characters(i.e) removing duplicates. String contains only lowercase characters ['a'-'z']

0 Answers  


Categories