In reversing of string is as easy as:


But not very same in . This is the code I am using to reverse integers in C:

#include <stdio.h>

int main(int argc, char *argv[])
    int number, right_digit;

    printf("Enter your number.\n");
    scanf("%i", &number);

    do {
        right_digit = number % 10;
        printf("%i", right_digit);
        number = number / 10;
    } while(number != 0);

    return 0;

The limitations of above program is:

  • It does not works on negative integers
  • It does not works on strings

The challenge is to reverse a string (not int) in minimum chars.

  • \$\begingroup\$ Should this be a complete program, or a function? should it read a string from stdin? \$\endgroup\$ – Hasturkun Sep 9 '13 at 15:34
  • \$\begingroup\$ @Hasturkun a complete program, that acts like above program (processes on enter); yes, from stdin. \$\endgroup\$ – Santosh Kumar Sep 9 '13 at 16:07

Browse other questions tagged or ask your own question.