Reader small image

You're reading from  Learn C Programming. - Second Edition

Product typeBook
Published inAug 2022
PublisherPackt
ISBN-139781801078450
Edition2nd Edition
Right arrow
Author (1)
Jeff Szuhay
Jeff Szuhay
author image
Jeff Szuhay

Jeff Szuhay is the principal developer at QuarterTil2 which specializes in graphics-rich software chronographs for desktop environments. In his software career of over 35 years, he has engaged in a full range of development activities from systems analysis and systems performance tuning to application design, from initial development through full testing and final delivery. Throughout that time, he has taught computer applications and programming languages at various educational levels from elementary school students to university students, as well as developed and presented professional, on-site training.
Read more about Jeff Szuhay

Right arrow

Using format specifiers for signed integers

Signed integers include integers that can have negative as well as positive values. The next example program is signedInt.c, and it begins as follows:

#include <stdio.h>
int main( void ) {
  int smallInt = 12;
  int largeInt = 0x7fffffff; // int32 max
  int negativeInt = -smallInt;
  unsigned anUnsigned = 130;
  long long int reallyLargeInt = 0x7fffffffffffffff; // int64 max
  // the other code snippets go here.
}

The values of smallIntlargeIntnegativeIntanUnsigned, and reallyLargeInt will be printed using various fields, precision, and alignment modifiers. Notice that largeInt is given a hexadecimal value that is the largest positive value a 32-bit integer can hold. Likewise, reallyLargeInit is given a hexadecimal value that is the largest positive value a 64-bit...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Learn C Programming. - Second Edition
Published in: Aug 2022Publisher: PacktISBN-13: 9781801078450

Author (1)

author image
Jeff Szuhay

Jeff Szuhay is the principal developer at QuarterTil2 which specializes in graphics-rich software chronographs for desktop environments. In his software career of over 35 years, he has engaged in a full range of development activities from systems analysis and systems performance tuning to application design, from initial development through full testing and final delivery. Throughout that time, he has taught computer applications and programming languages at various educational levels from elementary school students to university students, as well as developed and presented professional, on-site training.
Read more about Jeff Szuhay