When I executed it..the string was reversed but some special characters were appearing in front of the reversed string..so my teacher asked me to add
desstr[i]=0; to the program. Please let me know..y there was a need to add "desstr[i]=0;"??
Because all strings must be terminated with a null character ('\0', or just 0).
That's how cout (and many other functions that work with C strings) knows where the end of the string is.
Otherwise, it keeps going past the end of the string until it happens to run into a null character somewhere in memory that you're not supposed to be accessing.