關于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此類符號在后面會有講解*/
return 0;
}
/*這樣為什么也可以正常顯示,那char和float的意義在哪???*/
2016-12-19
這是因為“int weight = 82.5;?int isfat = 'y';“進行了自動類型轉換,自動轉換發生在不同數據類型運算時,在編譯的時候自動完成。自動轉換遵循的規則就好比小盒子可以放進大盒子里面一樣。