I’m a beginner at C, and using Turbo C++ compiler (16 bit).
In the software I’m writing, the maximum answer is around 32000. If I want a number larger than that, I use long int.
If I execute the following program:
#include <stdio.h>
void main()
{
long int x;
x=40000;
printf("%d", x);
}
Then I get an error that the constant value is long in function main().
How can I get an answer more that 32000 and get rid of this error?
also nw i change %d to %ld and use 40000L bt when i use unsigned integer then also i need to use ‘l’ with 40000//??
Use %ld in printf for the long int. %d is for int which only has 16 bits in your compiler. And for the error message, use x=40000L.