0
In python reversing of string is as easy as:
string[::-1]
But not very same in c. 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);
printf("\n");
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.
Should this be a complete program, or a function? should it read a string from stdin? – Hasturkun – 2013-09-09T15:34:18.390
@Hasturkun a complete program, that acts like above program (processes on enter); yes, from stdin. – Santosh Kumar – 2013-09-09T16:07:05.463