C PROGRAM TO PERFORM REVERSE OF A GIVEN STRING

ALGORITHM: 

    1. Start 

    2. Declare variables . 

    3. Read a String. 

    4. Check each character of string for alphabets or a special character by using isAlpha() . 

    5. Change the position of a character vice versa if it is alphabet otherwise remains same. 

    6. Repeat step 4 until reach to the mid of the position of a string. 

    7. Display the output of the reverse string without changing the position of special characters . 

    8. Stop.

PROGRAM:

#include <stdio.h>
#include <string.h>
int main()
{
   char s[100];

   printf("Enter the Given String :");
   gets(s);

   strrev(s);

   printf("Reverse String :%s", s);

   return 0;
}

OUTPUT:
Enter the Given String :a@gh%;j
Reverse String :j@hg%;a

Leave a comment