Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

31,104 questions

40,777 answers

573 users

How to check if string is palindrome in C

Learn & Practice SQL


113 views
asked May 18, 2017 by avibootz
edited May 19, 2017 by avibootz

2 Answers

0 votes
#include <stdio.h> 
#include <string.h> 
  
int main(int argc, char **argv) 
{ 
    char s[6] = "abcba", rev[6] = "";
    int j = 0;
     
    for(int i = strlen(s) - 1; i >= 0; i--, j++)
        rev[j] = s[i];
         
    rev[j] = '\0';
       
    if (strcmp(rev, s) == 0)
        printf("Palindrome\n");
    else
        printf("Not Palindrome");
     
    return(0);
}
  
   
/*
   
run:
   
Palindrome
  
*/

 





answered May 18, 2017 by avibootz
edited May 18, 2017 by avibootz
0 votes
#include <stdio.h> 
#include <string.h> 
 
int main(int argc, char **argv) 
{ 
    char s[6] = "abcba", rev[6] = "abcba";
    
    strcpy(rev, s);
    strrev(rev);
      
    if (strcmp(rev, s) == 0)
        printf("Palindrome\n");
    else
        printf("Not Palindrome");
    
    return(0);
}
 
  
/*
  
run:
  
Palindrome
 
*/

 





answered May 18, 2017 by avibootz

Related questions

2 answers 124 views
1 answer 81 views
1 answer 80 views
80 views asked Feb 21, 2016 by avibootz
2 answers 76 views
2 answers 82 views
...