How to check whether string is a palindrome, WITHOUT USING
STRING FUNCTIONS?

Answers were Sorted based on User's Feedback



How to check whether string is a palindrome, WITHOUT USING STRING FUNCTIONS?..

Answer / ramu gurram

#include<stdio.h>
void main()
{
char str[10]="liril";
int i,l,count=1;
printf("first find the string length as follow\n");
printf("\n\n");
for(l=0;str[l]!='\0';l++)
{
}
printf("length of the string %s is %d\n",str,l);
printf("\n\n");
for(i=0,l=l-1;l>=0;l--,i++)
{
if(str[i]!=str[l])
{
count++;
break;
}
}
if(count==1)
printf("given string is palindrom");
else
printf("given string is not palindrom");
}

Is This Answer Correct ?    20 Yes 4 No

How to check whether string is a palindrome, WITHOUT USING STRING FUNCTIONS?..

Answer / narasimharao

#include<stdio.h>
#include<conio.h>
void main()
{
char str[20]="malayalam",str1[20];
int i,j,k,c;
clrscr();
for(c=0;str[c]!='\0';c++)
{
}
printf("%d\n",c);
for(i=c-1,j=0;i>=0;i--,j++)
{
str1[j]=str[i];
}
printf("%s\n",str1);
k=1;
for(i=0;str[i]!='\0';i++)
{
if(str[i]!=str1[i])
{
k=0;
break;
}
}
if(k==1)
printf("Given String is Palindrome");
else
printf("Given String is Not Palindrome");
getch();
}

Is This Answer Correct ?    10 Yes 8 No

Post New Answer

More C Interview Questions

what is answer for perfect number????????????????

1 Answers  


What are the restrictions of a modulus operator?

0 Answers  


What is an anonymous union and where to apply that ?

3 Answers   HP,


Explain what are the different data types in c?

0 Answers  


How do you write a program which produces its own source code as its output?

4 Answers  






10. Study the code: void show() main() { show(); } void show (char *s) { printf("%sn",s); } What will happen if it is compiled & run on an ANSI C Compiler? A)It will compile & nothing will be printed when it is executed B)it will compile but not link C)the compiler will generate an error D)the compiler will generate a warning

5 Answers   Accenture,


Can a variable be both constant and volatile?

0 Answers  


Multiply an Integer Number by 2 Without Using Multiplication Operator

0 Answers  


What is the benefit of using an enum rather than a #define constant?

0 Answers  


how to make program without <> in libray.

0 Answers  


Define macros.

0 Answers   Tech Mahindra,


Write a C/C++ program that connects to a MySQL server and checks intrusion attempts every 5 minutes. If an intrusion attempt is detected beep the internal speaker to alert the administrator. A high number of aborted connects to MySQL at a point in time may be used as a basis of an intrusion.

2 Answers   Drona Solutions, Infosys, Vodafone, Webyog,


Categories