Mega Code Archive

 
Categories / C / Code Snippets
 

Read unsigned int, long and short from console

#include <stdio.h> int main(void) { unsigned u; long l; short s; printf("Enter an unsigned: "); scanf("%u", &u); printf("Enter a long: "); scanf("%ld", &l); printf("Enter a short: "); scanf("%hd", &s); printf("They are here: %u %ld %hd\n", u, l, s); return 0; }