How to check whether string is a palindrome, WITHOUT USING
STRING FUNCTIONS?
Answers were Sorted based on User's Feedback
#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 |
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 |
Difference between Function to pointer and pointer to function
how to find a 5th bit is set in c program
Reverse the part of the number which is present from position i to j. Print the new number. eg: num=789876 i=2 j=5 778986
What is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?
What are static variables, and where are they stored?
The difference between printf and fprintf is ?
Implement a function that returns the 5th element from the end in a singly linked list of integers in one pass.
Function calling procedures? and their differences? Why should one go for Call by Reference?
show how link list can be used to repersent the following polynomial i) 5x+2
What is the purpose of 'register' keyword?
How can I make a program in c to print 'Hello' without using semicolon in the code?
9 Answers C DAC, Practical Viva Questions,
Convert the following expression to postfix and prefix (A+B) * (D-C)