#include<stdio.h>#include<string.h>intmain(){int i,j,len=0;char str[50],revstr[50];printf("\n Enter a String to Reverse : ");// Use fgets to read input, with a maximum size of 50 charactersfgets(str,sizeof(str),stdin);// Remove the newline character from the end of the string
str[strcspn(str,"\r\n")]=0;// Count the length of the stringfor(i=0; str[i]!='\0'; i++){
len++;}
j=0;// Reverse the string by copying each character from the original string to the new string in reverse orderfor(i=len-1; i>=0; i--){
revstr[j++]=str[i];}printf("\n Reverse of the Given String is: %s",revstr);return0;}
OUTPUT:
Enter a String to Reverse : www.programming9.com
Reverse of the Given String is: moc.9gnimmargorp.www