C Program For String Palindrome

Get Certified in C Programming and Take Your Skills to the Next Level

Program 1

// Program for string palindrome without using inbuild function
#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
    char s[100];
    int i,j,f=0;
    printf("Enter a string: ");
    gets(s);
     i=0;
     j=strlen(s)-1;
     while(i<=j)
     {
           if(s[i]!=s[j])
           {
            f=1;
            break;
           }
        i++;
        j--;
     }
     if(f==0)
        printf("String is palindrome");
      else
        printf("String is not palindrome");
    // strcpy(s1,s);
    // //puts(s);
    // strrev(s1);
    // x=strcmp(s,s1);
    // if(x==0)
    //   printf("String is palindrome");
    //   else
    //   printf("String is not palindrome");
 return 0;
}

 

Did we exceed your expectations?
If Yes, share your valuable feedback on Google

courses

TechVidvan Team

TechVidvan Team provides high-quality content & courses on AI, ML, Data Science, Data Engineering, Data Analytics, programming, Python, DSA, Android, Flutter, full stack web dev, MERN, and many latest technology.

Leave a Reply

Your email address will not be published. Required fields are marked *