I want to know the range of numbers which can be used for 'a' and 'b' without getting error.(ie. the output should also give correct value. )
#include <stdio.h>
#include <stdlib.h>
int sum(int * , int *);
int main()
{
unsigned int a= 10;
int b = -30,c;
c=sum(&a,&b);
printf("sum of %d and %d is %d",a,b,c);
return 0;
}
int sum(int *p , int *q)
{
return *p+*q;
};
I gave a signed number to the variable 'a', which is declared as unsigned integer and '-30' for variable 'b'. I got correct output for values of a greater than -2147483618(-2147483617,-2147483616 and so on). But i got positive values for a=-2147483619 onwards. Why is it so? Please help me out.