I could use some help on the challenge Q’s.
Part 1 says to write a program that shows you how much a float “consumes”.
Here is what I came up with:
int main(int argc, const char * argv)
int i = 17; int *addressOfI = &i; printf("i stores its value at %p\n", addressOfI); *addressOfI = 89; printf("Now i is %d\n", i); printf("An int is %zu bytes\n", sizeof(i)); printf("A pointer is %zu bytes\n", sizeof(addressOfI));
printf(“A float is %zu bytes\n”, sizeof(float));
//This tells me the the float is 4 bytes. Is this correct? Is this the same as consuming?
Part 2 ask about the limits for the short :
I had to look up on google but here what I came across, the smallest is -32767 while the largest is 32767. Then, the largest # an unsigned short can store would be 65535.
This is where I got the information:
signed char: -127 to 127 (note, not -128 to 127; this accommodates 1's-complement platforms) unsigned char: 0 to 255 "plain" char: -127 to 127 or 0 to 255 (depends on default char signedness) signed short: -32767 to 32767 unsigned short: 0 to 65535 signed int: -32767 to 32767 unsigned int: 0 to 65535 signed long: -2147483647 to 2147483647 unsigned long: 0 to 4294967295 signed long long: -9223372036854775807 to 9223372036854775807 unsigned long long: 0 to 18446744073709551615
I would just like to confirm these are correct since there weren’t any post on these challenges.