网站大量收购闲置独家精品文档,联系QQ:2885784924

北京大学计算概论课件第十讲 函数.ppt

  1. 1、本文档共36页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
switch(month) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: if (day 31 || day 1) printf(\nYou have entered an invalid day!); break; case 2: if ( (year % 4 == 0 year % 100 != 0) || (year % 400 == 0) ) //is a leap year { if (day 29 || day 1) printf(\nYou have entered an invalid day!); } else // is not a leap year if (day 28 || day 1) printf(\nYou have entered an invalid day!); break; case 4: case 6: case 9: case 11: if (day 30 || day 1) printf(\nYou have entered an invalid day!); break; } Read an integer: Input a string consists of digit Convert the string into an integer when accept a ‘\n’ Report an error if other characters are detected Read an integer: #includestdio.h #includemath.h main() { int i=0,x=0;char b; printf(Please enter an integer); do {b=getchar(); x=pow(10,i)*b+x;i++;} while (b=1b=9); printf(%d,x); return 0; } Today’s Objectives introduction Function: definition, declaration and call Parameters and return value Program with functions Standard Library Functions What is a Function? Function in math: y=f(x); y=sin(x); y=(a*b); In Early computer program: macro; routine; subroutine; procedure; A small machine that transforms the data it receives into a finished product (x1,x2,…,xn) function ? y Function: definition; declaration and call Function declaration: Define the prototype of a function Function Definition : write a function name, parameter list, a set of instructions Calling a function: set the value of parameters and execute the function. Return and continue the original executing afterwards. Function prototypes The declaration statement for a function is referred to as a function prototype Declare the name of a function Declares the data type of the value that will be directly returned by the func

您可能关注的文档

文档评论(0)

ormition + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档