2007-10-04 12:02:39~資管坦克~
程式
#include
#include
int main(void)
{
short si1=-32768, si2=-32769, si3=32767, si4=32768;
unsigned long usi1=0, usi2=65535, usi3=-2, usi4=65537;
long lg1=-2147483648, lg2=2147483647, lg3=-2147483650, lg4=2147483648;
; printf("Data types of C Language:");
printf("1.int(long int)(long)n");
printf("2.short int(short)n");
printf("3.charn");
printf("4.floatn");
printf("5.doublen");
printf("Length of long int is %d:n", sizeof(long));
printf("Length of short int is %d:n", sizeof(short));
printf("Length of char int is %d:n", sizeof(char));
printf("Length of float int is %d:n", sizeof(float));
printf("Length of double int is %d:n",sizeof(double));
//驗證數值儲存範圍
//1. long
//2. unsigned long
//3. short
//4. unsigned short
printf("si1=%d, si2=%d, si3=%d, si4=%dn",si1,si2,si3,si4);
printf("Range of short int is %d ~ %d :n", si1,si3);
printf("usi1=%d, usi2=%d, usi3=%d, usi4=%dn",si1,si2,si3,si4);
printf("lg1=%d, lg2=%d, lgi3=%d, lg4=%dn",lg1,lg2,lg3,lg4);
system("pause");
return 0;
}
#include
int main(void)
{
short si1=-32768, si2=-32769, si3=32767, si4=32768;
unsigned long usi1=0, usi2=65535, usi3=-2, usi4=65537;
long lg1=-2147483648, lg2=2147483647, lg3=-2147483650, lg4=2147483648;
; printf("Data types of C Language:");
printf("1.int(long int)(long)n");
printf("2.short int(short)n");
printf("3.charn");
printf("4.floatn");
printf("5.doublen");
printf("Length of long int is %d:n", sizeof(long));
printf("Length of short int is %d:n", sizeof(short));
printf("Length of char int is %d:n", sizeof(char));
printf("Length of float int is %d:n", sizeof(float));
printf("Length of double int is %d:n",sizeof(double));
//驗證數值儲存範圍
//1. long
//2. unsigned long
//3. short
//4. unsigned short
printf("si1=%d, si2=%d, si3=%d, si4=%dn",si1,si2,si3,si4);
printf("Range of short int is %d ~ %d :n", si1,si3);
printf("usi1=%d, usi2=%d, usi3=%d, usi4=%dn",si1,si2,si3,si4);
printf("lg1=%d, lg2=%d, lgi3=%d, lg4=%dn",lg1,lg2,lg3,lg4);
system("pause");
return 0;
}
這程式好眼熟..?
是C++的作業阿!!
我還沒寫完ㄉ說... 2007-10-07 11:49:14