C program to reverse the given word using string

#include<stdio.h>
#include<string.h>

int main()
 {
   char str[100], rev;
   int i=0,c,j;
   printf("Enter the string :\n");
   gets(str);
   j = strlen(str)-1;
   while (i < j)
   {
  rev = str[i];
      str[i] = str[j];
      str[j] = rev;
      i++;
      j--;
   }

   printf("\nReverse string is\n%s",str);
   return 0;
}

OUTPUT

C program to reverse the given word using string

Post a Comment

0 Comments