Wednesday, May 20, 2020

Find the string is palindrome or not in C

  • Program :
#include <stdio.h>
#include <string.h>
void isPalindrome(char str[])
{
 
    int l = 0;
    int h = strlen(str) - 1; 
    while (h > l)
    {
        if (str[l++] != str[h--])
        {
            printf("\n%s is Not Palindrome", str);
            return;
        }
    }
    printf("\n%s is palindrome", str);
}
int main()
{
    printf("\n----------------PALINDROME OR NOT----------------");
    isPalindrome("madam");
    isPalindrome("moni");
    isPalindrome("wow");
    return 0;
}


  • Output :


No comments:

Post a Comment

Function Overloading in C++

https://monitechvenkat1620.blogspot.com Program : #include <iostream> using namespace std; int c(int x, int y) {   return...