How to check whether string is a palindrome, WITHOUT USING
STRING FUNCTIONS?
Answer Posted / 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 View All Answers
Which is more efficient, a switch statement or an if else chain?
What is the purpose of main( ) in c language?
Explain what is the difference between #include and #include 'file' ?
What is the difference between text and binary i/o?
Why ca not I do something like this?
Write a program that takes a 5 digit number and calculates 2 power that number and prints it(should not use big integers and exponential functions)
Write a program to implement a round robin scheduler and calculate the average waiting time.Arrival time, burst time, time quantum, and no. of processes should be the inputs.
What is function prototype?
How do we make a global variable accessible across files? Explain the extern keyword?
What is the difference between call by value and call by reference in c?
Does sprintf put null character?
Explain can the sizeof operator be used to tell the size of an array passed to a function?
How can I open files mentioned on the command line, and parse option flags?
How can I display a percentage-done indication that updates itself in place, or show one of those twirling baton progress indicators?
Is register a keyword in c?