#include<stdio.h>
#include<string.h>
void main()
{
char str[50],revstr[50];
int i=0,j=0;
clrscr();
printf("Enter the string to be reversed : ");
scanf("%s",str);
for(i=strlen(str)-1;i>=0;i--)
{
revstr[j]=str[i];
j++;
}
revstr[j]='\0';
printf("Input String : %s",str);
printf("\nOutput String : %s",revstr);
getch();
}
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char string1[20],string2[20];
int i,j,length;
printf("\nEnter the string : ");
gets(string1);
length=strlen(string1);
for(i=0;i<length;i++)
{
for(j=length;j<=0;j--)
string2[j]=string1[i];
}
printf("\nReversed string is : %s",string2);
getch();
}
This is a homework question that has been asked several times before. Please check previous answers and also please check previous answers for any further questions that you may have. Others have done your current course and asked the questions before you.
You might consider paying attention in class and reading your text book, that strategy will give you the answers that you need.
sdfdg
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.
This program only suits PHP. If you want a proper one try C program for it available on web <body> <?php if(isset($_POST['submit'])) { $text = $_POST['text']; $string = mysql_real_escape_string($text); $invert = strrev($string); if($string == $invert) { echo "<br>Given number is a palindrome!!"; } else { echo "<br>Given number is not a palindrome!!"; } } ?> <form method="post"> <input type="text" name="text" id="text" /> <input type="submit" name="submit" value="Submit" id="submit" onclick="<?php $_SERVER['PHP_SELF']; ?>" /> </form> </body>
int main(int argc, char* argv[]){char a[10],b[10];printf("enter any string\n");scanf("%s",a);printf("a=%s",a);strcpy(b,a);strrev(b);printf("\nb=%s",b);if(strcmp(a,b)==0)printf("\nstring is palindrome");elseprintf("\nnot pelindrome");return 0;}
Not possible through html. Use php strrev function. For eg:
A predefined function can reverse a string as shown below:echo strrev('pizza'); // outputs: azzip
By writing user defined function.
sdfdg
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);
with a loop. len= strlen (s); p= s; q= s+len-1; while (p<q) { (swap) ++p; --q; }
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';}
You can do this: <?php if ( $word === strrev( $word ) ) { echo "The word is a palindrome"; } else { echo "The word is not a palindrome"; }
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
#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; }
use the strrev() function on the given string and compare with original string.If both are equal they are palindromes else not.
#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"); }