Palindrome in c without using string function






#include<stdio.h>

int main(){
  char str[100];
  int i=0,j=-1,flag=0;

  printf("Enter a string: ");
  scanf("%s",str);

  while(str[++j]!='\0');
  j--;

  while(i<j)
      if(str[i++] != str[j--]){
           flag=1;
           break;
      }
     

  if(flag == 0)
      printf("The string is a palindrome");
  else
      printf("The string is not a palindrome");

  return 0;
}







Alogrithm:
**





10. Write a c program to add two numbers without using addition operator.
11. Write a c program to subtract two numbers without using subtraction operator.
15. Write a c program to solve quadratic equation.
18. Write a c program which passes structure to function.
28. Write a c program which takes password from user.
29. Write a scanf function in c which accept sentence from user.
30. Write a scanf function in c which accept paragraph from user.

6 comments:

Balasubramanian said...

This Website is EXTRA ORDINARILY useful.Keep doing this great job.

PinkPretty said...

really really good website i have ever seen with this much of programs.. it is very helpful to me......

Sora said...
This comment has been removed by the author.
Ads.txt said...

Its good helping us

Ads.txt said...

Its good helping us

Unknown said...

What's wrong with this program???


#include
#include
int main()
{
char str[15],rev[15];
int len,i,j;
printf("Enter the string to be checked:");
scanf("%s",str);
len=strlen(str);
j=len-1;
for(i=0;i<len;i++)
{
rev[j]=str[i];
j--;
}
printf("%s\n%s\n%d\n",str,rev,len);
if(strcmp(str,rev))
printf("String is not PALINDROME!\n");
else
printf("String is Palindrome!\n");
}