Friday, 20 March 2015

String Reverse in C



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include<stdio.h>
void boss(char *p)
{   char a;
 int i,j;
  for(j=0;p[j]!='\0';j++)
  {
            for(i=0;i<j;i++)
   {
                 a = p[i];
                 p[i]=p[j];
                 p[j]=a;
   }
  }

return;
}

int main()
{
   char s[20];
   printf("Enter The string to be reverse: ");
   gets(s);
   boss (s);
   printf("The Reversed string is: %s \n",s);
   return 0;
}

0 comments:

Post a Comment

 

Subscribe to our Newsletter

Contact our Support

Through the contact form

Our Team Memebers