林中誠 程式設計 20121002 功課一 #include #include
int main() { short int no1=150; int no2=150; long int no3=150; printf("%d\n",sizeof(no1)); printf("%d\n",sizeof(no2)); printf("%d\n",sizeof(no3)); system("pause"); return 0;
}
林中誠 程式設計 20121002 功課二 #include #include
int main() {
char ch1='a'; char ch2[]="a"; printf("ch1=%c 有%d 位元\n",ch1,sizeof(ch1)); printf("ch2=%s 有%d 位元\n",ch2,sizeof(ch2)); system("pause"); return 0;
}
|
林中誠 程式設計 20121002 功課一 #include #include
int main() { unsigned short int s1=-1; short int s2=32768; printf("s1=%d\n",s1); printf("s2=%d\n",s2); system("pause"); return 0;
}
林中誠 程式設計 20121002 功課二 #include #include
int main() { char Str_1[6]="Hello"; char Str_2[6]={ 'H', 'e', 'l', 'l','o','\0'}; char Str_3[ ]="Hello"; char Str_4[ ]={ 'H', 'e', 'l', 'l', 'o', '!' };
printf("%s\n",Str_1); printf("%s\n",Str_2); printf("%s\n",Str_3); printf("%s\n",Str_4);
system("pause"); return 0;
}
|
林中誠 程式設計 20121002 功課一 #include #include
int main() { float f1=123.4568357109375F; float f2=21341372.1357912; double d1=123456789.123456789123;
printf("f1=%f\n",f1); printf("f2=%f\n",f2); printf("d1=%f\n",d1);
system("pause"); return 0;
}
林中誠 程式設計 20121002 功課二 #include #include
int salary=17500;
int main() { printf("salary=%d\n",salary); { int salary=22000; printf("salary=%d\n",salary); } printf("salary=%d\n",salary) system("pause"); return 0;
}
|