write a program of palindrome(madam=madam) using pointer?

Answer Posted / priyanka

#include<stdio.h>
#include<conio.h>
int stpal(char str[50]);
void main()
{
char str[50];
int pal;
clrscr();
printf(“nnt ENTER A STRING…: “);
gets(str);
pal = stpal(str);
if(pal)
printf(“nt THE ENTERED STRING IS A PALINDROME”);
else
printf(“nt THE ENTERED STRING IS NOT A PALINDROME”);
getch();
}
int stpal(char str[50])
{
int i = 0, len = 0, pal = 1;
while(str[len]!=’&#8242;)
len++;
len–;
for(i=0; i<len/2; i++)
{
if(str[i] == str[len-i])
pal = 1;
else
{
pal = 0;
break;
}
}
return pal;
}

Is This Answer Correct ?    2 Yes 11 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is floating point constants?

687


What are pragmas and what are they good for?

572


What is the meaning of c in c language?

595


What is the incorrect operator form following list(== , <> , >= , <=) and what is the reason for the answer?

937


What is dynamic variable in c?

565






Explain how can I convert a number to a string?

647


How can I recover the file name given an open stream?

553


What is extern storage class in c?

510


Design a program which assigns values to the array temperature. The program should then display the array with appropriate column and row headings.

1768


What is malloc and calloc?

573


What are pointers in C? Give an example where to illustrate their significance.

748


How can I find out how much free space is available on disk?

628


If a five digit number is input through the keyboard, write a program to print a new number by adding one to each of its digits.For example if the number that is input is 12391 then the output should be displayed as 23402

3247


What is a node in c?

548


What does %c mean in c?

647