intconv.c 504 B

123456789101112131415161718
  1. /* intconv.c -- some mismatched integer conversions */
  2. #include <stdio.h>
  3. #define PAGES 336
  4. #define WORDS 65618
  5. int main(void)
  6. {
  7. short num = PAGES;
  8. short mnum = -PAGES;
  9. printf("num as short and unsigned short: %hd %hu\n", num,
  10. num);
  11. printf("-num as short and unsigned short: %hd %hu\n", mnum,
  12. mnum);
  13. printf("num as int and char: %d %c\n", num, num);
  14. printf("WORDS as int, short, and char: %d %hd %c\n",
  15. WORDS, WORDS, WORDS);
  16. return 0;
  17. }