资源描述:
《C语言学习第三章(英文版)课件.ppt》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Chapter3Types,OperatorsandExpressions3.1VariableNames3.2DataTypesandSizes3.3Constants3.4Declarations3.5ArithmeticOperators3.6RelationalandLogicalOperators3.7TypeConversions3.8IncrementandDecrementOperators3.9AssignmentOperatorsandExpressions3.10ConditionalExpressio
2、ns3.11PrecedenceandOrderofEvaluationOutlineVariableNamesDeclarationsArithmeticOperatorsRelationalandLogicalOperatorsIncrementandDecrementOperatorsKeypoints3.1VariablenamesWhatarevariables?Anamedareainthecomputermemory,intendedtocontainvaluesofacertainkind(integers,
3、realnumbers,etc.)TheycontainthedatayourprogramworkswithTheycanbeusedtostoredatatobeusedelsewhereintheprogramInshort–theyaretheonlywaytomanipulatedata3.1VariablenamesVariablesinmemoryWheneverwewritethevariablename(e.g.my_int),weasktoreadthevalueofthatvariableIfwewri
4、te&variable_name,weaskfortheaddressofthatvariable3.1VariablenamesVariablenamingrulesLetters,digits,underscoresiCSE_5along_name_that_isnt_very_usefulfahrenheitFirstcharactercannotbeadigit5a_CSEisnotvalidCasesensitiveCSE_5aisdifferentfromcse_5aThemaximumlengthis31cha
5、racters3.1VariablenamesKeywordsareexplicitlyreservedwordsthathaveastrictmeaningasindividualtokensinC.Keywordscannotbeusedasvariablenames3.2DataTypesandSizestheDataTypeintInmathematics,thenaturalnumbersare0,1,2,3,…,andthesenumbers,alongwiththeirnegatives,comprisethe
6、integers.Onamachine,onlyafiniteportionoftheseintegersarerepresentableforagivenintegraltype.3.2DataTypesandSizesBecausethesizeofanintvariesfromoneCsystemtoanother,thenumberofdistinctvaluesthatanintcanholdissystem-dependent.ForTurboC,therangeofanint(2bytes)is-32768(-
7、215)to32767(+215-1).ForVC++,therangeofanint(4bytes)is-231to+231-1.3.2DataTypesandSizesTheIntegralTypeslongandshortInC,thedatatypeintisconsideredthe”natural”or”usual”typeforworkingwithintegers.Theotherintegraltypes,suchaschar,short,andlong,areintendedformorespeciali
8、zeduse.shortandlongintegerswouldusuallyoccupytwoandfourbytes,respectively.3.2DataTypesandSizesLongvariablesaredeclaredusingthekeywordlong,andshor