with a loop.
len= strlen (s);
p= s;
q= s+len-1;
while (p<q) {
(swap)
++p;
--q;
}
Not possible through html. Use php strrev function. For eg:
Without any function is impossible. So I'll assume you mean any coded function, in which case the predefined function below is your answer.$string = strrev($string);
By writing user defined function.
A predefined function can reverse a string as shown below:echo strrev('pizza'); // outputs: azzip
String library function is one which is used to perform an operation in C-programming,without which library functions likestrlen(),strcp(),strcmp(),strdup(),strrev(),etc..,.can be performed
use the strrev() function on the given string and compare with original string.If both are equal they are palindromes else not.
sdfdg
You could use a function like this:function isPalindrome($string) {$string = strtolower($string);return (strrev($string) == $string) ? true : false;}and then to check a palindrome call an if statement like so:if(isPalindrome($test)) {echo $test.' is a palindrome';}else {echo $test.' is not a palindrome';}
#include<stdio.h> main() { char a[20],b[20]; printf("enter a string"); scanf("%s",&a); strcpy(b,a);//copies string a to b strrev(b);//reverses string b if(strcmp(a,b)==0)//compares if the original and reverse strings are same printf("\n%s is a palindrome",a); else printf("\n%s is not a palindrome",a); return 0; }
You can do this: <?php if ( $word === strrev( $word ) ) { echo "The word is a palindrome"; } else { echo "The word is not a palindrome"; }
Here is a simple C program to check if a string is a palindrome: #include <stdio.h> #include <string.h> int main() { char str[100], rev[100]; printf("Enter a string: "); fgets(str, sizeof(str), stdin); str[strcspn(str, "\n")] = 0; // Remove newline character strcpy(rev, str); strrev(rev); // Reverse the string if (strcmp(str, rev) == 0) printf("The string is a palindrome.\n"); else printf("The string is not a palindrome.\n"); return 0; } This program takes a string input, reverses it, and then compares the original string with the reversed string to determine if it is a palindrome.
#include<stdio.h> #include<conio.h> #include<string.h> void main() { char a[15],b[15]; printf("Enter the string\n"); scanf("%s",&a); strcpy(b,a); strrev(a); if(strcmp(a,b)==0) printf("The String is a palindrome"); else printf("The String is not a palindrome"); }