mirror of
https://github.com/Rushilwiz/comp211.git
synced 2025-04-03 19:00:17 -04:00
21 lines
423 B
C
21 lines
423 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
int main() {
|
|
short a = -3;
|
|
int b = (int) a;
|
|
unsigned short c = (unsigned short) a;
|
|
unsigned int d = (unsigned int) c;
|
|
|
|
// The "h" modifier here tells printf that
|
|
// a is a short. Otherwise the value would
|
|
// be treated like an int.
|
|
printf("%hx\n", a);
|
|
printf("%x\n", b);
|
|
printf("%hx\n", c);
|
|
printf("%x\n", d);
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|
|
|