#include <stdio.h> int main(int argc, char *argv[]) { char str[1024]; char revStr[1024]; int charCount = 0, x = 0, i = 0; printf("Enter the string : "); gets(str); while(str[charCount] != '\0') charCount++; for(x=charCount-1; x >= 0; x--){ revStr[i] = str[x]; i++; } revStr[i] = '\0'; printf("\nReversed string : %s \n\n", revStr); }OUTPUT :
Enter the string : TESTSTRING
Reversed string : GNIRTSTSET
No comments:
Post a Comment