C语言编程学习课件 (10).pdf
《C语言编程学习课件 (10).pdf》由会员分享,可在线阅读,更多相关《C语言编程学习课件 (10).pdf(20页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、Programming In CProgramming In C Programming In CProgramming In C The movie“Roaring Across the Horizon”Programming In CProgramming In C in mathematics you use x for multiplication,in C you use*.The*is used rather than to avoid any possible confusion with a variable called x.Note also that/,rather th
2、an,is used for division.Programming In CProgramming In C#include stdio.h void main()char s=7;int n=4;printf(7/4=%dn,s/n);printf(7.0/4=%fn,(float)s/n);outputoutput:7/4=1 7/4=1 not 1.75not 1.75 7.0/4=1.750000 7.0/4=1.750000 Programming In CProgramming In C The remainder operation is very interesting i
3、n C.The remainder operation is very interesting in C.The remainder is also called the modulus.Each time the hour hand reaches the 12 oclock,and it indicates that it has rotated once and the modulus becomes 0.Starting from 0,the modulus will increase by 1 in turn.Therefore,the modulus of the hour han
4、d ranges from 0 to 11;the modulus of the minute hand ranges from 0 to 59.Programming In CProgramming In C#include stdio.h#include math.h void main()char s=A,t;/generate the random capital letter t=s+rand()%26;printf(s=%c,t=%cn,s,t);Programming In CProgramming In C#include stdio.h#include math.h void
5、 main()char s=a,t;/generate the random lowercase letter t=s+rand()%26;printf(s=%c,t=%cn,s,t);Programming In CProgramming In C#include stdio.h#include math.h void main()char s=0,t;/generate the numeric symbols t=s+rand()%10;printf(s=%c,t=%cn,s,t);Programming In CProgramming In C How to simulate and g
6、enerate a license plate number in How to simulate and generate a license plate number in Kunming?Kunming?The modulus operation has not only the special operators,but also the restrictions on the two operands involved in the operation.It can only operate on integers,that is,integer and data of charac
7、ter type can find the modulus.The floating numbers cannot find the modulus.Find the modulus for a negative number,and the sign of the result is the same as the number before the percent.Programming In CProgramming In C -7%2 :-1 15%-4:3 With the operations of division and modulus,how to take out the
8、With the operations of division and modulus,how to take out the number of each digit of an integer?number of each digit of an integer?518/100 5 518/10%10 1 518%10 8 Type conversions and casts When doing calculations involving mixed data types,C ranks the data types in this order:promotion or widenin
9、g of the data For calculations involving mixed data types,C automatically converts the value in the lower data type to a higher type.Promotion will cause no loss of data,because the higher data types occupy more memory than the lower types and can therefore hold the data precisely.Type conversions a
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- C语言编程学习课件 10 语言 编程 学习 课件 10
限制150内