K & R C Programs Exercise 3-4.

K and R C, Solution to Exercise 3-4:
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 represent the binary numbers in a negative sign.There are a number of ways of representing signed integers in binary, for example, signed-magnitude, excess-M, one’s complement and two’s complement. In this program , we handle the problem that is, the value of n equal to -(2 to the power (wordsize – 1))(C Programming Language (2nd Edition) by Brian W.Kernighan & Dennis M.Richie page no 64) by changing the (n /= 10) > 0 to (n /= 10) != 0. 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
***********************************************************/


#include <stdlib.h>
#include <stdio.h>
#include <limits.h>
#define abs(x) ((x) < 0 ? -(x) : (x))
void itoa(int n, char s[]);
void reverse(char s[]);

int main(void) {
char buffer[20];

printf("INT_MIN: %dn", INT_MIN);
itoa(INT_MIN, buffer);
printf("Buffer : %sn", buffer);

return 0;
}
//itoa: convert to n characters in s - modified.
void itoa(int n, char s[])
{
void int i, sign;
void everse(char s[]);
sign = n;
i = 0;
do{
s[i++] = abs(n%10) + '0';
}while((n/=10)!=0);
if(sign < 0)
s[i++] = '-';
s[i] = '