Example 1: c print long
unsigned long n;
long m;
printf("%lu %ld", n, m);
Example 2: how to print int in c
#include
int main() {
int number;
printf("Enter an integer: ");
scanf("%d", &number);
printf("You entered: %d", number);
return 0;
}
Example 3: what is a long long int in c
#include
#include
#include
#define FailedToEducate 101
#define Success 400
int main(void) {
/*
A long int is:
32-bit compiler:
MIN: -2,147,483,648
MAX: 2,147,483,647
unsigned MAX: 4,294,967,295
64-bit compiler:
MIN: -9,223,372,036,854,775,808
MAX: 9,223,372,036,854,775,807
unsigned MAX: 18,446,744,073,709,551,615
Therefore...a long int will either be
-2,147,483,648 and 2,147,483,647 for a 32-bit compiler
or -9,223,372,036,854,775,808 and
9,223,372,036,854,775,807 for a 64-bit compiler,
whilst a long long int will just be
-9,223,372,036,854,775,808 and
9,223,372,036,854,775,807
I hope this made sense!
*/
bool userUnderstands=true;
if(userUnderstands) {
exit(Success);
} else {
exit(FailedToEducate);
}
}
Example 4: print long in c
You must use %ld to print a long int, and %lld to print a long long int.