C program to reverse a string without using string function.

Program satement

Write a program to take a input string and reverse it character by character without using string function strrev.

Program to reverse a string

Output

Explanation:

Here in program we store input string into character array a.
By using standard string function strlen we calculate length of a string.
As we know the last index of the string is always ‘\0’, therefore we set index to length-1.
In this way from the last index, we reverse a string and print it.

Help others by sharing the content!

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.