1.合適的資料型別
a.人口 int、short、unsigned、unsigned short
b.***影碟的** float
c.字母 char
d.字母出現的次數 int 或者unsigned
2.長度超過int所能表示的範圍要用long
3. 獲得乙個32位的有符號整數型別,可以使用那些可移植資料型別?每種選擇的理由是什麼?
4. a. '\b' char 游標退一格
b. 1066 int
c. 99.44 float
d. 0xaa unsigned int 十六進製制
e. 2.0e30 double
5.#include
main(void)
float g;
float tax,rate;
g = 2e1;
tax = rate * g
6.%d12
%#x0x3
%c'c'
%e2.34e07
%c'\040'
%f7.0
%ld6l
%f6.0
7.%ud012
%le2.9e05l
%c's'
%ld100000
%c'n'
%f20.0f
%x0x44
8.int imate = 2;
long short = 53456;
char grade = 'a';
float log = 2.71828;
printf("the odds against the %d where %d to 1.\n", imate, shot);
printf("a score of %f is not an %c grade.\n", log,grade);
9.回車
ch = '\r';//轉義序列
ch = 13;//十進位制
ch = '\015';//八進位制
ch = '\xd' = 『\0x0d』;//十六進製制
10.#include
int main(void)
int crows, legs;
printf("how many cow legs did you count?\n");
scanf("%d", legs);
cows = legs / 4;
printf("that implies there are %d cows.\n", cows);
11.\n換行
\\反斜槓
\"雙引號
\t水平製表符
程式設計2.輸入ascii值,輸出相應字元
#include int main(void)
3、發出警報,列印字元
#include int main(void)
4、輸入浮點數,以小數和指數形式顯示
#include int main(void)
5.輸入年齡,計算秒
#include int main(void)
6.輸入夸脫顯示水分子
#include int main(void)
7.
#include #include int main(void)
else if(type == 2)
printf("請輸入%s\n", iunit);
scanf("%f", &inputnum);
printf("%e%s\n", inputnum * conver, ounit);
return 0;
}
c primer plus 第3章 處理資料
c 的 基 本 類 型 分 為 兩 組 一 組 由 存 儲 為 整 數 的 值 組 成 另 一 組 由 儲存 為 浮 點 格 式 的 值 組 成 整 型 之 間 通 過 存 儲 值 時 使 用 的 內 存 量 及 有 無 符 號 來 區 分 整 型 從 最小 到 最 大 依 次 是 bool cha...
C Primer Plus 第3章 處理資料
第3章 處理資料 c 提供了內建型別來儲存兩種資料 整數 沒有小數的數字 和浮點數 帶小數的數字 為滿足程式設計師的各種需求,c 為每一種資料都提供了幾個型別。本章將要討論這些型別,包括建立變數和編寫各種型別的常量。另外,還將討論c 是如何處理不同型別之間的隱式和顯式轉換的。1.變數名 1 以兩個下...
C Primer Plus 第3章 資料和C
習題1 檢視當前系統整數的上限和下限 include include int max,int min include intmain void 2147483647,2147483648,2147483647 1.inf00e 000 1.175493e 040 process exited aft...