C

Asked • 05/03/19

How do you format an unsigned long long int using printf?

#include <stdio.h> int main() {  unsigned long long int num = 285212672; //FYI: fits in 29 bits  int normalInt = 5;  printf("My number is %d bytes wide and its value is %ul. A normal number is %d.\\n", sizeof(num), num, normalInt);  return 0; }Output: My number is 8 bytes wide and its value is 285212672l. A normal number is 0.I assume this unexpected result is from printing the `unsigned long long int`. How do you `printf()` an `unsigned long long int`?

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.