關(guān)于char,float,int
#include <stdio.h>
int main()
{
int age = 15;
int height = 162;
int weight = 82.5;
int isfat = 'y';
printf("年齡:%d 歲\n", age);
printf("身高:%d CM\n", height);
printf("體重:%f KG\n", weight);
printf("是否屬于肥胖兒童:%c\n", isfat);
/*%d,%f,%c此類符號(hào)在后面會(huì)有講解*/
return 0;
}
/*這樣為什么也可以正常顯示,那char和float的意義在哪???*/
2016-12-19
這是因?yàn)椤癷nt weight = 82.5;?int isfat = 'y';“進(jìn)行了自動(dòng)類型轉(zhuǎn)換,自動(dòng)轉(zhuǎn)換發(fā)生在不同數(shù)據(jù)類型運(yùn)算時(shí),在編譯的時(shí)候自動(dòng)完成。自動(dòng)轉(zhuǎn)換遵循的規(guī)則就好比小盒子可以放進(jìn)大盒子里面一樣。