This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
user:psechris:portfolio:datastrucuresproject1 [2013/09/04 03:46] – created psechris | user:psechris:portfolio:datastrucuresproject1 [2013/09/04 03:48] (current) – psechris | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ======Project: | ||
+ | A project for CSCS 2330 by Paul Sechrist during the Spring 2013. | ||
+ | |||
+ | =====Objectives===== | ||
+ | Play with data type size example, experiment with it a little. | ||
+ | =====Code===== | ||
+ | <code c 1> | ||
+ | |||
+ | #include < | ||
+ | #include < | ||
+ | |||
+ | int main() { | ||
+ | |||
+ | /* Data Types | ||
+ | Size | ||
+ | %hhd Signed char 1 | ||
+ | %hhu unsigned char 1 | ||
+ | %hd | ||
+ | %hu | ||
+ | %d signed int 4 | ||
+ | %u unsigned int 4 | ||
+ | %ld | ||
+ | %lu | ||
+ | %llu signed long long int 8 | ||
+ | %llu unsigned long long int 8 | ||
+ | %f float 0 | ||
+ | %lf | ||
+ | %llf long double | ||
+ | |||
+ | */ | ||
+ | |||
+ | signed char sc=0; | ||
+ | unsigned char uc=0; | ||
+ | signed short int ssi=0; | ||
+ | unsigned short int usi=0; | ||
+ | signed int si=0; | ||
+ | unsigned int ui=0; | ||
+ | signed long int sli=0; | ||
+ | unsigned long int uli=0; | ||
+ | signed long long int slli=0; | ||
+ | unsigned long long int ulli=0; | ||
+ | float f=0; | ||
+ | double d=0; | ||
+ | long double ld=0; | ||
+ | |||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | |||
+ | return(0); | ||
+ | } | ||
+ | |||
+ | </ | ||
+ | ====Execution==== | ||
+ | <cli> | ||
+ | |||
+ | lab46: | ||
+ | a signed char is 1 bytes | ||
+ | lower bound is: -128 | ||
+ | upper bound is: 127 | ||
+ | ---------------------------- | ||
+ | an unsigned char is 1 bytes | ||
+ | lower bound is: 0 | ||
+ | upper bound is: 255 | ||
+ | ---------------------------- | ||
+ | a signed short int is 2 bytes | ||
+ | lower bound is: -32768 | ||
+ | upper bound is: 32767 | ||
+ | ---------------------------- | ||
+ | an unsigned short int is 2 bytes | ||
+ | lower bound is: 0 | ||
+ | upper bound is: 65535 | ||
+ | ---------------------------- | ||
+ | a signed int is 4 bytes | ||
+ | lower bound is: -2147483648 | ||
+ | upper bound is: 2147483647 | ||
+ | ---------------------------- | ||
+ | an unsigned int is 4 bytes | ||
+ | lower bound is: 0 | ||
+ | upper bound is: 4294967295 | ||
+ | ---------------------------- | ||
+ | a signed long int is 8 bytes | ||
+ | lower bound is: -9223372036854775808 | ||
+ | upper bound is: 9223372036854775807 | ||
+ | ---------------------------- | ||
+ | an unsigned long int is 8 bytes | ||
+ | lower bound is: 0 | ||
+ | upper bound is: 18446744073709551615 | ||
+ | ---------------------------- | ||
+ | a signed long long int is 8 bytes | ||
+ | lower bound is: -9223372036854775808 | ||
+ | upper bound is: 9223372036854775807 | ||
+ | ---------------------------- | ||
+ | an unsigned long long int is 8 bytes | ||
+ | lower bound is: 0 | ||
+ | upper bound is: 18446744073709551615 | ||
+ | ---------------------------- | ||
+ | a float is 0.000000 bytes | ||
+ | lower bound is: 0.500000 | ||
+ | upper bound is: -0.500000 | ||
+ | ---------------------------- | ||
+ | an double is 0.000000 bytes | ||
+ | lower bound is: 0.000000 | ||
+ | upper bound is: -1.000000 | ||
+ | ---------------------------- | ||
+ | a long double is 0.000000 bytes | ||
+ | lower bound is: 0.500000 | ||
+ | upper bound is: -0.500000 | ||
+ | ---------------------------- | ||
+ | lab46: | ||
+ | </ | ||
+ | =====Reflection===== | ||
+ | Good way to review data types and C in general. | ||
+ | =====References===== | ||
+ | Matt's examples. |