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]!=’′)
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
What is floating point constants?
What are pragmas and what are they good for?
What is the meaning of c in c language?
What is the incorrect operator form following list(== , <> , >= , <=) and what is the reason for the answer?
What is dynamic variable in c?
Explain how can I convert a number to a string?
How can I recover the file name given an open stream?
What is extern storage class in c?
Design a program which assigns values to the array temperature. The program should then display the array with appropriate column and row headings.
What is malloc and calloc?
What are pointers in C? Give an example where to illustrate their significance.
How can I find out how much free space is available on disk?
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
What is a node in c?
What does %c mean in c?