Problem :
find the given string is palindrome or not without using string.h header file , why this condition is given because without string.h header file we cannot use any function like strlen,strcmp,strcpy,strrev.
Solution:
#include<stdio.h>
#include<conio.h>
void main()
{
char a[100],i,j,equal=0,k;
clrscr();
printf("\n enter the string ");
scanf("%s",a);
for(i=0;a[i]!='\0';i++);
for(j=i-1,k=0;a[k]!='\0';j--,k++)
if(a[j]==a[k])
equal++;
if(equal==i)
printf("\n the %s is palindrome",a);
else
printf("\n the %s is not palindrome",a);
getch();
}
find the given string is palindrome or not without using string.h header file , why this condition is given because without string.h header file we cannot use any function like strlen,strcmp,strcpy,strrev.
Solution:
#include<stdio.h>
#include<conio.h>
void main()
{
char a[100],i,j,equal=0,k;
clrscr();
printf("\n enter the string ");
scanf("%s",a);
for(i=0;a[i]!='\0';i++);
for(j=i-1,k=0;a[k]!='\0';j--,k++)
if(a[j]==a[k])
equal++;
if(equal==i)
printf("\n the %s is palindrome",a);
else
printf("\n the %s is not palindrome",a);
getch();
}
No comments:
Post a Comment