Jan 16, 2012

K & R C Programs Exercise 4-12.

K and R C, Solution to Exercise 4-12:
K and R C Programs Exercises provides the solution to all the exercises in the C Programming Language (2nd Edition). You can learn and solve K&R C Programs Exercise.
Write a C program to convert an integer into a string by calling a recursive routine.Recursive routine is the programming technique that a routine invoking itself again and again. Read more about C Programming Language .

* You can use all the programs on  www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact info@c-program-example.com
* To find more C programs, do visit www.c-program-example.com
* and browse!
*                      Happy Coding

void itoa(int n, char s[]);
int main(void) {
 char buffer[20];

 //for testing!
 printf("INT_MIN: %d\n", INT_MIN);
 itoa(INT_MIN, buffer);
 printf("Buffer : %s\n", buffer);

 return 0;
/* itoa: convert n to characters in s; recursive */
void itoa(int n, char s[])
 static int i;
 if(n / 10)
  itoa(n /10, s);
  i = 0;
  if(n < 0)
   s[i++] = '-';
 s[i++] = abs(n) %10 + '0';
 s[i] = '\0';

Read more Similar C Programs
C Basic
C Strings
K and R C Programs Exercise
You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

To browse more C Programs visit this link