Write programs for String Reversal & Palindrome check

Showing Answers 1 - 6 of 6 Answers

poty

  • Nov 15th, 2007
 

REVERSE A STRING

#include<stdio.h>
#include<string.h>
main()
{
 char str[50],revstr[50];
 int i=0,j=0;
 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]='';
 printf("Input String : %s",str);
 printf("nOutput String : %s",revstr);
 getch();
}

  Was this answer useful?  Yes

snrmukund

  • Nov 16th, 2008
 

main()
{
char str[10];
int i=0;
clrscr();
printf("Enter the name to be reversed :");
scanf("%s",&str);
for(i=strlen(str);i>=0;i--)
{
printf("%c",str[i]);
}
getch();
}

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions