Program to perform Reversal of String


#include <iostream.h>
#include <conio.h>
#include<stdio.h>
void main ( )
{
        int count , i ;
        char line[40] , reverse[40] ;
        puts ("Enter A String - ") ;
        gets (line) ;
        count = 0 ;
        while (line[count] != '\0')
            count++ ;
        count-- ;
        for(i=0 ; i<40 ; i++)
            reverse[i] = 0 ;
        i = 0 ;
        while (count >= 0)
        {
            reverse[count] = line[i] ;
            count-- ;
            i++ ;
        }
        puts ("\nThe reversed string is - ") ;
        puts (reverse) ;
        getch ( ) ;
}

0 comments:

Post a Comment

 
 
 
 


Copyright © 2012 http://codeprecisely.blogspot.com. All rights reserved |Term of Use and Policies|