Wednesday, 21 March 2012

Reverse of any string using C language


/*Print Reverse of a string*/

#include<stdio.h>
int main()
{
    char string[]="hi i am Nilesh";
    char RevString[50];
    int i=-1,j=0;
   
      while(str[++i]!='\0');//logic to print reverse strin
        { //we can use "strrev" function also
         while(i>=0)
           {
            rev[j++] = str[--i];
           }
       rev[j]='\0';
      }
    printf("Reverse of string is : %s",rev);
  
    return 0;

} //End of main

No comments:

Post a Comment

Compiler for C,C++ and Python {paste your programme to see the output}