C Program To Reverse a String

In this post, we will learn how to reverse a string in C Programming language.

C Program To Reverse a String

So, without further ado, let’s begin this tutorial.

C Program To Reverse a String

// C Program To Reverse a String
#include <stdio.h>
#include <string.h>

int main(){
    char s[60];
    int i, count;
    
    // Asking for Input
    printf("Enter a string: ");
    scanf("%s", s);
    
    count = strlen(s);
    
    for (i = count; i >= 0; i--){
        printf("%c", s[i]);
    }
    return 0;
}

Output

Enter a string: Hello
olleH

Conclusion

I hope after going through this post, you understand how to reverse a string in C Programming language.

If you have any doubt regarding the program, feel free to contact us in the comment section. We will be delighted to help you.

Also Read:

Leave a Comment

Your email address will not be published. Required fields are marked *