Question:How to reverse a string in c without using reverse function 

Answer 
#include<stdio.h>
int main(){
    char str[50];
    char rev[50];
    int i=-1,j=0;

    printf("Enter any string : ");
    scanf("%s",str);
   
    while(str[++i]!='\0');

    while(i>=0)
     rev[j++] = str[--i];

    rev[j]='\0';
  
    printf("Reverse of string is : %s",rev);
  
    return 0;
}
Sample output: Enter any string : cquestionbank.blogspot.com Reverse of string is : moc.topsgolb.knabnoitseuqc 

+ ExplanationNot Moderated
+ Report
Total Preview: 878
How to reverse a string in c without using reverse function
Copyright © 2024. Powered by Intellect Software Ltd