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

ch10 Formatted InputOutput.ppt

  1. 1、本文档共35页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
ch10 Formatted InputOutput

Chapter 10 - Formatted Input/Output 10.1 Introduction In this chapter Presentation of results scanf and printf Streams (input and output) gets, puts, getchar, putchar (in stdio.h) 10.2 Streams Streams Sequences of characters organized into lines Each line consists of zero or more characters and ends with newline character ANSI C must support lines of at least 254 characters Performs all input and output Can often be redirected Standard input – keyboard Standard output – screen Standard error – screen More Chapter 11 10.3 Formatting Output with printf printf Precise output formatting Conversion specifications: flags, field widths, precisions, etc. Can perform rounding, aligning columns, right/left justification, inserting literal characters, exponential format, hexadecimal format, and fixed width and precision Format printf( format-control-string, other-arguments ); Format control string: describes output format Other-arguments: correspond to each conversion specification in format-control-string Each specification begins with a percent sign(%), ends with conversion specifier printf 库函数 格式化输出函数 printf(格式控制, 输出变量列表); 格式控制:用双引号括起来的字符串 格式说明 = % + 格式字符 将输出列表中的对应数据转换成指定格式输出 普通字符:除格式说明外的其他字符,原样输出 输出列表:需要输出的一些数据,可以是变量或表达式 例1: #include stdio.h void main( ) { int r = 50 ; float area = 3.5; printf(r = %d, area = %f, r, area); } /*输出结果:r = 50, area = 3.500000 */ 10.4 Printing Integers Integer Whole number (no decimal point): 25, 0, -9 Positive, negative, or zero Only minus sign prints by default (later we shall change this) 1. Print Program Output 10.5 Printing Floating-Point Numbers Floating Point Numbers Have a decimal point (33.5) Exponential notation (computers version of scientific notation) 150.3 is 1.503 x 102 in scientific 150.3 is 1.503E+02 in exponential (E stands for exponent) use e or E f – print floating point with at least one digit to left of decimal g (or G) - prints in f or e with no trailing zeros (1.2300 becomes 1.23) Use exponential

文档评论(0)

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

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

1亿VIP精品文档

相关文档