第6章循环控制4177752学案.pptVIP

  • 2
  • 0
  • 约4.85千字
  • 约 35页
  • 2016-08-10 发布于湖北
  • 举报
College of Information Science and Engineering, Wuhan University of Science and Technology College of Information Science and Engineering, Wuhan University of Science and Technology 第六章 循环控制 概述 C语言可实现循环的语句: 用goto 和 if 构成循环 while 语句 do ~ while 语句 for 语句 循环的嵌套(难点) goto 功能:无条件转移语句 说明: 不能用整数作标号 只能出现在goto所在函数内,且唯一 只能加在可执行语句前面 限制使用goto语句 goto语句及用goto构成循环 goto语句一般格式: goto 语句标号; ….….. 标号:语句; 例 用if 和goto语句构成循环,求 /*ch6_1_1.c*/ #include stdio.h main() { int i,sum=0; i=1; loop: if(i=100) { sum+=i; i++; goto loop; } printf(%d,sum); } sum=0+1 sum=1+2=3

文档评论(0)

1亿VIP精品文档

相关文档