.
Previous Next

Write a C program which reverse the string ?

/* C program which reverse the string */
#include <stdio.h>
#include<conio.h>
#include <string.h>
int main(){
    char str[100];
    char rev[100];
    int i,j;
    clrscr();
    printf("Enter String : ");
    scanf("%s",str);
    i = 0; j = strlen(str)-1;
    while(j>=0){
       rev[i] = str[j];
       i++;j--;
    }
    rev[i] = '\0';
    printf("Given  String  : %s\n",str);
    printf("Reverse String : %s\n",rev);
    getch();
    return 0;
}

Previous Next