C Language ExerciseChapter1Word格式文档下载.docx
《C Language ExerciseChapter1Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《C Language ExerciseChapter1Word格式文档下载.docx(7页珍藏版)》请在冰豆网上搜索。
了解负数的原理
exam7
了解数据丢失
exam8
了解数据溢出
exam9
参考代码:
#include<
stdio.h>
voidexam1(inta);
voidexam2();
voidexam3();
voidexam4();
voidexam5();
voidexam6();
voidexam7();
voidexam8();
voidexam9();
voidexam10();
main()
{
printf("
hello,world!
\n"
);
exam1(5);
exam2();
exam3();
exam4();
exam5();
exam6();
exam7();
exam8();
exam9();
}
voidexam1(inta)
***exam1***\n"
Thevalueofais%d!
a);
voidexam2()
chara;
charA;
a='
a'
;
A='
A'
***exam2***\n"
Thevalueofais%c!
Thedecimalvalueofais%d!
ThevalueofAis%c!
A);
a=a-32;
Nowthevalueofais%c!
voidexam3()
inta;
***exam3***\n"
a=100;
Nowthevalueofais%d!
voidexam4()
inti;
***exam4***\n"
Thehexvalueofais%x!
Thebinaryvalueofais:
b"
for(i=0;
i<
8;
i++)
if((a<
<
i)&
0x80)
printf("
%c"
'
1'
else
0'
voidexam5()
longl;
unsignedul;
unsignedintui;
shortintsi;
unsignedshortintusi;
charc;
unsignedcharuc;
l=0x8877665544332211;
ul=0x8877665544332211;
i=0x8877665544332211;
ui=0x8877665544332211;
si=0x8877665544332211;
usi=0x8877665544332211;
c=0x8877665544332211;
uc=0x8877665544332211;
***exam5***\n"
Thevalueoflis%x!
l);
Thevalueofulis%x!
ul);
Thevalueofiis%x!
i);
Thevalueofuiis%x!
ui);
Thevalueofsiis%x!
si);
Thevalueofusiis%x!
usi);
Thevalueofcis%x!
c);
Thevalueofucis%x!
uc);
voidexam6()
floatf;
doubledf;
longdoubleldf;
ldf=1234.12345678901234567890123456789;
df=ldf;
f=df;
***exam6***\n"
Thevalueofldfis%f!
ldf);
Thevalueofdfis%f!
df);
Thevalueoffis%f!
f);
Thevalueofldfis%15.15f!
Thevalueofdfis%15.15f!
Thevalueoffis%9.8f!
voidexam7()
intc;
c=-100;
***exam7***\n"
Thevalueofcis%d!
Thehexvalueofcis%x!
c=100;
voidexam8()
unsignedlongul;
l=123456789;
ul=l;
i=l;
ui=l;
si=i;
usi=i;
c=i;
uc=i;
***exam8***\n"
Thevalueoflis%d!
Thevalueofulis%d!
Thevalueofiis%d!
Thevalueofuiis%d!
Thevalueofsiis%d!
Thevalueofusiis%d!
Thevalueofucis%d!
voidexam9()
unsignedshortintusi_1,usi_2;
unsignedcharuc_1,uc_2;
charc_1,c_2;
usi_1=30000;
usi_2=usi_1+40000;
ui=usi_1+40000;
uc_1=100;
uc_2=uc_1+200;
usi=uc_1+200;
***exam9***\n"
Thevalueofusi_2is%d!
usi_2);
Thevalueofuc_2is%d!
uc_2);
c_1=-100;
c_2=c_1-50;
si=c_1-50;
Thevalueofc_2is%d!
c_2);