chapter6--C程序设计(英文课件).pptVIP

  • 1
  • 0
  • 约3.13千字
  • 约 16页
  • 2017-12-26 发布于河北
  • 举报
chapter6--C程序设计(英文课件)

Chapter6 loop-structure By: wangxia E-mail: wangxia1026@163.com contents 6.0 review 6.1 introduction 6.2 “goto” statement and goto-loop 6.3 “while” statement 6.4 “do-while” statement 6.5 “for” statement 6.6 nested loop 6.7 comparison among loops contents 6.8 “break” statement and “continue” statement 6.9 give a example exercises review 1、if-statement: if(10=x=20) wrong if(x=10x=20) right 2、tc3.0: menu—windows: message output 3、switch---case 6.1 introduction 1、application widely 2、mode: Goto + if While Do-while for 6.2 “goto” statement and goto-loop 1、how to use? Goto statement number; 2、example: 3、we donot use “goto-statement” if we can. 6.3 “while” statement 1、be used to implement “when-loop”. 2、characteristic: ---- first judge, (1) then implement 3、be used when loop-times is not fixed. 6.3 “while” statement Example: 6.4 “do-while” statement 1、how to use? 2、first implement then judgement 3、when expression=0; end; 6.4 “do-while” statement 6.3 “while” statement ex6.3 用do--while语句求∑n。先画出流程图. 6.3 compare “while” with “do-while main ( ) {int sum=0,i; scanf(“%d”,i); while (i=10) { sum=sum+i; i++; } printf(“sum=%d”,sum); } 6.5 “for” statement 1、how to use? 2、how to implement? (1) at first, get the result of “expression1”。 (2) expression2, if it is “true”, then, carry out built-in statements,turn to “(3)” ; else,end the loop,turn to “(5)” . 6.5 “for” statement (3)expression3; (4)turn to “(2)”; (5)end the loop; 6.5 “for” statement 3、simple form: for( initialize the loop-variable; loop-condition; increment of loop-variable) statement; 6.5 “for” statement 4、three expressions can be omitted. ex: for(;i=10;i++) for(;;i++) for(i=1;;i++) for(;;;) 5、for(sum=0,i=1;i=100;i++) sum=sum+i; for(i=0,j=100;i=j;i++,j--) k+=i*j; * * ex6.1:用if语句和goto语句构成循

文档评论(0)

1亿VIP精品文档

相关文档