Monday, 24 March 2014

write a program to reverse a string.


#include<stdio.h>
#include<string.h>
main()
{
char s[90],temp;
int n,i,j;
printf("enter the string:");
scanf(" %[^\n]s",s);
n=strlen(s);
for(i=0,j=n-1;i<j;i++,j--)
 {
 temp=s[j];
  s[j]=s[i];
  s[i]=temp;
 }
printf("%s",s);
}

No comments:

Contact Form

Name

Email *

Message *