Unsigned long int in C language

How can I print an unsigned long int in C language?

To print an unsigned long integer in C language, you can use the %lu format specifier in the printf() function. Here’s an example code snippet:

#include <stdio.h>

int main() {
    unsigned long int num = 1234567890123456;
    printf("The number is: %lu\n", num);
    return 0;
}

In the code above, we have declared an unsigned long integer num and initialized it with a large value. We then used the %lu format specifier in the printf() function to print the value of num. The output of this program will be:

output:

The number is: 1234567890123456

Note that the unsigned the keyword is used to ensure that the variable can only store non-negative values. If you try to print an unsigned long integer using %d instead of %lu, the output will not be correct, and you may get unexpected results.

1 thought on “Unsigned long int in C language”

  1. Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?

    Reply

Leave a Comment