Program in C++ to check a given string is palindrome or not Using recursive function
Related Programs
C Program
#include<stdio.h> #include<string.h> void palindrome(char *str){ int len, i; len = strlen(str); for(i = 0; i < len / 2; i++){ if(str[i] != str[len - 1 - i]){ printf("%s is not palindrome string.",str); return; } } printf("%s is palindrome string.",str); } int main(){ char *str; str = malloc(50); // type casting is optional printf("Enter a string :- "); scanf("%s",str); palindrome(str); return 0; }
C++ Program
#include<iostream> #include<string.h> #include<stdlib.h> using namespace std; void palindrome(char *str){ int len, i; len = strlen(str); for(i = 0; i < len / 2; i++) if(str[i] != str[len - 1 - i]){ cout<<str<<" is not palindrome string."; return; } cout<<str<<" is palindrome string."; } int main(){ char *str; str =(char*)malloc(50); cout<<"Enter a string :- "; cin>>str; palindrome(str); return 0; }
Output :-
Related Programs
- Program in C++ to check a given string is palindrome or not
- Program in C to check the given string is palindrome or not.
- Program in c to check a number is palindrome or not using function
- Program in c to check a number is palindrome or not
Recursive function
- Program in C and C++ to print reverse of a given number using recursive function
- Program in C and C++ to print reverse of a given string using recursive function
- Program in C and C++ to print Nth natural numbers in reverse order using recursive function
- Program in C and C++ to find sum of digits of a given number using recursive function
- Program in C and C++ to check a given number is Armstrong or not Using recursive function
- Program in C and C++ to find sum of nth numbers Using recursive function
0 Comments