第二讲 C#语言基础(数据类型)
- 格式:ppt
- 大小:1.16 MB
- 文档页数:54
郑州信息科技职业学院教案授课题目:C语言的运算符和表达式、数据类型的转换第二讲:C语言的运算符和表达式、数据类型的转换授课时数:3教学目的与教学要求:1、掌握C语言的各种运算;2、掌握C语言中运算过程中不同的数据类型的转换。
主要内容:1、算术运算符和算术表达式;2、关系运算和逻辑运算;3、自增、自减运算;4、赋值运算;5、其他运算;6、表达式和表达式语句;7、自动类型转换和赋值转换;8、强制类型转换。
重点和难点:1、自增、自减运算;2、自动类型转换和赋值转换;3、强制类型转换。
教学方法和手段教具多媒体演示和板书相结合授课内容:第三章3、1运算符与表达式C的运算符有以下几类:本章主要介绍算术运算符(包括自增自减运算符)、赋值运算符、逗号运算符,其它运算符在以后相关章节中结合有关内容陆续进行介绍。
3、1、1 算术运算符和算术表达式1、算术运算符+(加法运算符。
如3+5)-(减法运算符或负值运算符。
如5-2,-3)*(乘法运算符。
如3*5)/(除法运算符。
如5/3,5.0/3)%(模运算符或求余运算符,%要求两侧均为整型数据。
如7%4的值为3)。
除了负值运算符-单目运算符外,其它都是双目运算符。
说明:(1)两个整数相除的结果为整数,如5/3的结果为1,舍去小数部分。
(2)如果参加+,-,*,/运算的两个数有一个为实数,则结果为double型,因为所有实数都按double 型进行计算。
(3)求余运算符%,要求两个操作数均为整型,结果为两数相除所得的余数。
求余也称为求模。
一般情况,余数的符号与被除数符号相同。
例如:-8%5=-3;8%-5=32、算术表达式算术表达式:用算术运算符和括号将运算对象(也称操作数)连接起来的、符合C语法规则的式子,称为算术表达式。
运算对象可以是常量、变量、函数等。
例如,下面是一个合法的C算术表达式。
a*b/c-1.5+’a’。
注意:C语言算术表达式的书写形式与数学表达式的书写形式有一定的区别:(1)C语言算术表达式的乘号(*)不能省略。
only once and understand it, so they can save time for doing other things. Other students, however, might need to listen to the same dialogue again and again to understand it. Using iPads is especially h__72__ to the students who are learning a language at different paces.The students who are using the new tool in some courses are also happy. They believe that using iPads is a more enjoyable way to learn (like listening to stories and watching movies). The class has become much more interesting and creative.There are other advantages for students. By using iPads, they can pay some attention to the material and learn more. Teaching notes are s__73__ in their iPads and are easy to find. Some students spend more time studying now. "I can listen to my language material or watch teaching videos on the bus, instead of having to wait till I get home," a student explained.But many adults c__74__ that technologies like iPads are doing harm to students. They worry that students might use iPads to download teaching notes and use them to chest during exams. Some believe that iPads may separate students from each other. If a student spends more time watching videos on an iPad, he will have f__75__ chances to have face-to-face communication with others.However, technologies are a__76__ a part of most students' day-to-day lives. As for cheating, teachers can ask students to hand in their iPads when they take exams. Education needs to make c__77__ with the times as technology is playing an important part. We should look forward to a wonderful future when iPads and other technologies can add a lot to the classroom.71. including 72. helpful 73. stored 74. complain 75. few 76. already 77. changes首字母填空同步练习3 (2014中考)A school newspaper T h e Te e n s asked over one thousand teenagers how they spent theirspare time. Here they report the r 81 of the survey. It’s not at all surprising to learn that mostteens said they wanted more free time. Most have less than an hour a day for after-school activities.P 82 activity was popular among both girls and boys, averaging between three to six首字母填空同步练习4 (2017中考)A Delicious MealTony is Chinese American. His family members gather together and serve a traditional Chinese meal once a week. Last week Tony i_______1______his friend Amy for it.Tony’s family was preparing dinner when Amy arrived. The family was cooking vegetables with hot oil. The k______2____ was filled with many good smells. “You can help me set the table.” Tony told his friend. They gave each person a pair of chopsticks, a soup bowl, a soup spoon, and a rice bowl on a plate.“Where are the forks and knives?” Amy asked.“Oh, you won’t n ____3_____those.” Tony explained.” I will show you how to use chopsticks. Don’t worry.”Tony’s mother put different foods which were unfamiliar to Amy onto big plates. She asked the kids to carry the food-filled plates out to the table. Amy carried roast duck. It was one of the f _____4_____dishes she recognized.Amy was a little nervous about eating with chopsticks. Tony gave her instructions on how to do it. Amy finally managed to hold the chopsticks. Just when she picked up a piece of chicken in her chopsticks, her fingers s___5_____ lost control of them, and the chicken flew across the table. It landed in Tony’s soup with a splash(飞溅). E___6______ at the table smiled.Tony’s father kindly brought out a fork and knife. He handed them to Amy .Amy felt more c__7_______. She ate the rest of her dinner easily. It was delicious!At the end of the meal, Amy was given a fortune cookie(签语饼干). She broke itopen and read the small note inside,” If you practice hard, you will learn many things.” Amy laughed and said,” if you let me take home a pair of chopsticks, my fortune may come true!1. invited2. kitchen3. need4. few5. suddenly6. Everyone7. comfortable【解析】试题分析:本文记叙了美国女孩Amy在好朋友Tony(华侨)家参加家宴的有趣故事。
第二讲主要内容运算符表达式一.运算符1.算术运算符和算术表达式C语言的运算符具有不同的优先级,而且还有一个特点,就是它的结合性。
在表达式中,各运算量参与运算的先后顺序不仅要遵守运算符优先级别的规定,还要受运算符结合性的制约,以便确定是自左向右进行运算还是自右向左进行运算。
这种结合性是其它高级语言的运算符所没有的,因此也增加了C语言的复杂性。
C运算符简介C语言的运算符可分为以下几类:1.算术运算符:用于各类数值运算。
包括加(+)、减(-)、乘(*)、除(/)、求余(或称模运算,%)、自增(++)、自减(--)共七种。
2.关系运算符:用于比较运算。
包括大于(>)、小于(<)、等于(==)、大于等于(>=)、小于等于(<=)和不等于(!=)六种。
3.逻辑运算符:用于逻辑运算。
包括与(&&)、或(||)、非(!)三种。
4.赋值运算符:用于赋值运算,分为简单赋值(=)、复合算术赋值(+=,-=,*=,/=,%=)和复合位运算赋值(&=,|=,^=,>>=,<<=)三类共十一种。
5.逗号运算符:用于把若干表达式组合成一个表达式(,)。
6.指针运算符:用于取内容(*)和取地址(&)二种运算。
7.求字节数运算符:用于计算数据类型所占的字节数(sizeof)。
8.特殊运算符:有括号(),下标[],成员(→,.)等几种。
9.条件运算符:这是一个三目运算符,用于条件求值(?:)。
10.位操作运算符:参与运算的量,按二进制位进行运算。
包括位与(&)、位或(|)、位非(~)、位异或(^)、左移(<<)、右移(>>)六种。
1.1算术运算符和算术表达式1.基本的算术运算符●加法运算符“+”:加法运算符为双目运算符,即应有两个量参与加法运算。
如a+b,4+8等。
具有左结合性。
●减法运算符“-”:减法运算符为双目运算符。