Skip to content
Home » C program to reverse a string

C program to reverse a string

Below is the code to reverse a string

#include <stdio.h>
#include <string.h>
int main(){
    char s[100];
    printf("Enter the string:\n");
    gets(s);
    int i,len;
    len=strlen(s);
    for(i=0;i<len;len--){
        printf("%c",s[len-1]);
        
    }
}

Output:

Enter the string:
Computer Science
ecneicS retupmoC