Sunday, 20 March 2016

C Program For Reverse A String Without (srtrev) Using Library Function

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

int main()
{
//Ghanendra Yadav
   char str[100], temp;
   int i, j = 0;

   printf("\nEnter the string :");
   gets(str);

   i = 0;
   j = strlen(str) - 1;

   while (i < j) {
      temp = str[i];
      str[i] = str[j];
      str[j] = temp;
      i++;
      j--;
   }

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


Output:-


No comments:
Write comments

Recommended Posts × +