QUES=> Function to find
out whether a string is palindrome or not using pointers.
CODE=>
CODE=>
#include<stdio.h>
#include<conio.h>
#include<string.h>
void fun(char *a,int l);
void main()
{
char n[20];
int l;
clrscr();
printf("ENTER THE STRING:");
gets(n);
l=strlen(n);
fun(&n,l);
getch();
}
void fun(char *a,int l)
{
char b[20];
int i=0,j=0,count=0;
for(i=0,j=l-1;i<l,j>=0;i++,j--)
{
if(*(a+i)==*(a+j))
{
*(b+j)=*(a+i);
}}
for(i=0;i<l;i++)
{
if(*(b+i)==*(a+i))
{
count++;
}
}
if(count==l )
{
printf("count=%d STRING IS PALINDROME",count);
}
else
{
printf("count=%d STRING IS NOT PALINDROME",count);
}
}
OUTPUT=>
No comments:
Post a Comment