Put an l (lowercased letter L) directly before the specifier.
unsigned long n;
long m;
printf("%lu %ld", n, m);
Answer from postfuturist on Stack OverflowPrintf long long int in C with GCC? - Stack Overflow
Printing long int value in C - Stack Overflow
how to print long long int (s64_t) values using printk or printf
c - How do you format an unsigned long long int using printf? - Stack Overflow
If you are on windows and using mingw, gcc uses the win32 runtime, where printf needs %I64d for a 64 bit integer. (and %I64u for an unsinged 64 bit integer)
For most other platforms you'd use %lld for printing a long long. (and %llu if it's unsigned). This is standarized in C99.
gcc doesn't come with a full C runtime, it defers to the platform it's running on - so the general case is that you need to consult the documentation for your particular platform - independent of gcc.
For portable code, the macros in inttypes.h may be used. They expand to the correct ones for the platform.
E.g. for 64 bit integer, the macro PRId64 can be used.
int64_t n = 7;
printf("n is %" PRId64 "\n", n);
You must use %ld to print a long int, and %lld to print a long long int.
Note that only long long int is guaranteed to be large enough to store the result of that calculation (or, indeed, the input values you're using).
You will also need to ensure that you use your compiler in a C99-compatible mode (for example, using the -std=gnu99 option to gcc). This is because the long long int type was not introduced until C99; and although many compilers implement long long int in C90 mode as an extension, the constant 2147483648 may have a type of unsigned int or unsigned long in C90. If this is the case in your implementation, then the value of -2147483648 will also have unsigned type and will therefore be positive, and the overall result will be not what you expect.
Use printf("%ld",a);
Have a look at format specifiers for printf
Use the ll (el-el) long-long modifier with the u (unsigned) conversion. (Works in windows, GNU).
printf("%llu", 285212672);
%d--> for int
%u--> for unsigned int
%ld--> for long int or long
%lu--> for unsigned long int or long unsigned int or unsigned long
%lld--> for long long int or long long
%llu--> for unsigned long long int or unsigned long long
If you want to print a variable in C, you have to have a format code, much like formatted printing in python.
printf("%lli", total);
where "%lli" is the format specifier for a long long int.
long long p; { printf("%lli\n", p); }
when you need to print long long you must use %lli to represent long long