c语言英文版课件

c语言英文版课件

ID:22021981

大小:381.50 KB

页数:36页

时间:2018-10-21

c语言英文版课件_第1页
c语言英文版课件_第2页
c语言英文版课件_第3页
c语言英文版课件_第4页
c语言英文版课件_第5页
资源描述:

《c语言英文版课件》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、IntroductiontoComputer (CProgramming)SoftwareCollege,NortheasternUniversity2007,9Chapter3OperatorsandExpressions3.1introductionCoperatorscanbeclassifiedintoanumberofcategories.Theyinclude:Arithmeticoperators.Relationaloperators.Logicaloperators.Assign

2、mentoperators.Incrementanddecrementoperators.Conditionaloperators.Bitwiseoperators.Specialoperators.3.2ArithmeticoperatorsOperatorMeaning+Additionorunaryplus-Subtractionorunaryminus*Multiplication/Division%ModulodivisionExamples:a-b,a+b,a*b,a/b,a%bExa

3、mple3.1TheProgramshowstheuseofintegerarithmetictoconvertagivennumberofdaysintomonthsanddays.main(){intmonths,days;printf(“Enterdays”);scanf(“%d”,&days);months=days/30;days=days%30;printf(“Months=%ddays=%d”,months,days);}OutputEnterdays265Months=8Day

4、s=25Enterdays364Months=12Days=4Enterdays45Months=1Days=153.3RelationalOperatorsCsupportssixrelationaloperatorsinall:OperatorsMeaningisgreaterthan>=isgreaterthanorequalto==isequalto!=isnotequaltoExample4.5<=104.5<-10-35

5、>=010<7+5a+b=c+d?RelationalOperatorComplementsAmongthesixrelationaloperators,eachoneisacomplementofanotheroperator. >iscomplementof<= = ==iscomplementof!= Wecansimplifyanexpressioninvolvingthenotandthelessthanoperatorsusingthecomplemen

6、tsasshownbelow: ActualoneSimplifiedone !(x=y !(x>y)x<=y !(x!=y)x==y !(x<=y)x>y !(x>=y)x

7、

8、meaninglogicalOR!meaninglogicalNOTExample:TruthTableOp_1Op_2Valueof

9、theExpressionop_1&&op_2op_1

10、

11、op_2Non_zeroNon_zero11Non_zero0110Non_zero110011Examples:1.if(age>55&&salary<1000)2.if(number<0

12、

13、number>1000)3.5AssignmentOperatorsChasasetof‘shorthand’operatorsoftheform:vop=exp;wherevisavariable,expisanexpressionopisaCbi

14、naryarithmeticoperatorop=isknownastheshorthandassignmentoperatorvop=exp;isequivalenttov=vop(exp);Examples:x+=y+1;isequivalenttox=x+(y+1);x+=3;isequivalenttox=x+3;ShorthandAssignmentOperatorsStatementwithsimpleStatementwithassignmentoperatorsho

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。