Write a c program to check given string is palindrome number or not





#include<string.h>
#include<stdio.h>
int main(){
  char *str,*rev;
  int i,j;
  printf("\nEnter a string:");
  scanf("%s",str);
  for(i=strlen(str)-1,j=0;i>=0;i--,j++)
      rev[j]=str[i];
      rev[j]='\0';
  if(strcmp(rev,str))
      printf("\nThe string is not a palindrome");
  else
      printf("\nThe string is a palindrome");
  return 0;
}




Definition of Palindrome string:

A string is called palindrome if it symmetric. In other word a string is called palindrome if string remains same if its characters are reversed. For example: asdsa
If we will reverse it will remain same i.e. asdsa

Example of string palindrome:  a,b, aa,aba,qwertrewq etc.






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.

7 comments:

  1. here in the above program

    char str[10],rev[10];

    its cannot be pointer as it is holding the array length

    ReplyDelete
  2. thnx for d programs.

    ReplyDelete
  3. can any1 explain dis program in detail

    ReplyDelete
  4. wat about this..

    void checkpalindrome(char* inString)
    {
    int i, j;
    int len = strlen(inString);
    for(i = 0, j = strlen(inString)-1; i > len\2 && j > len\2; i++, j--)
    {
    if(inString[i] != inString[j])
    break;
    }
    if(i == len/2 && j == len\2)
    printf("Palindrome\n");
    else
    printf("Not palindrome\n");
    }
    }

    ReplyDelete
  5. i got output thank u so much

    ReplyDelete
  6. I find my answer thank u

    ReplyDelete
  7. ye program chalega hi nhiiiiiiiiiiii

    ReplyDelete

Share It