hi as an exersize i was asked to write a program that will print out the size of int short long float double and long double. the following code is what i came up with (copied from the example in the chapter)
Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("size of int is: %zu\n", sizeof(int));
printf("size of short is: %zu\n", sizeof(short));
printf("size of long is: %zu\n", sizeof(long));
printf("size of float is: %zu\n", sizeof(float));
printf("size of double is: %zu\n", sizeof(double));
printf("size of long double is: %zu\n", sizeof(long double));
return 0;
}
when run i get the following answers int = 4 short = 2 long = 8 float = 4 double = 8 and long double = 16
the text said that a signed int can be upto 32767 on a 16 bit machine (mine is 64) but as an int only has 4 slots ie 1111 the max number is 15!!!!!!!!!!!!!!!!! so how do i get any number over that
coop