palindrome for strings and numbers----Can anybody do the
prog?

Answer Posted / shruti

//the palindrome for string can also be written as below,
without using inbuilt functions.

void main()
{
char str[10];
int flag = 0;
int i , j;

puts("ENTER THE STRING");
fflush(stdin);
gets(str);


for(i = 0 ; str[i] != '\0' ; i++);
i--;

for(j = 0 ; j<i ; j++ , i--)
{
if(str[j] == str[i])
flag = 1;
else
{
flag = 0;
break;
}
}

if(flag == 1)
puts("STRING IS A PALINDROME");
else
puts("STRING IS NOT A PALINDROME");
}

Is This Answer Correct ?    4 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the acronym for ansi?

626


Why we write conio h in c?

559


Can we change the value of #define in c?

582


Describe explain how arrays can be passed to a user defined function

597


What is operator precedence?

639






Is c language still used?

533


What is const volatile variable in c?

572


How can I manipulate individual bits?

604


What is a substring in c?

583


#include main() { enum _tag{ left=10, right, front=100, back}; printf("left is %d, right is %d, front is %d, back is %d",left,right,front,back); }

710


What is %g in c?

613


How to write a program for machine which is connected with server for that server automatically wants to catch the time for user of that machine?

1584


What is the use of putchar function?

646


What is self-referential structure in c programming?

655


how to write a c program to print list of fruits in alpabetical order?

1786