Advertisement
tonygms3

Question 7 Assignment

Dec 23rd, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.51 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. int main()
  4. {
  5.     char pal[150];
  6.     char temp[150];
  7.  
  8.     printf("\nEnter a string to check if palindrome or not\n");
  9.     gets(pal); //takes input from user
  10.  
  11.     strcpy(temp,pal); //copies the input to another temporary array
  12.     if(strcmp(strrev(pal),temp)==0) //compares to see if it returns a non zero value or not
  13.     {
  14.         printf("%s is a palindrome",temp);
  15.     }
  16.     else
  17.     {
  18.         printf("%s is not a palindrome",temp);
  19.     }
  20.  
  21.  
  22.  
  23.     return 0;
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement