…™업무일지。

[smart]이재우-20140313

엔지니어2 2014. 3. 13. 08:53
728x90

 

2014. 03. 13 수업 및 과제 


 

07. 반복실행을 명령하는 반복문

      

 7.1 while

[예제]

#include <stdio.h>
int main()
{
  int iCnt;
  iCnt=0;  

  while(3>iCnt)        /* 조건: (논리연산자)참/거짓으로 판단 */
  {
    printf("test\n");
    ++iCnt;  
  }
  return 0;
}

[결과]

 

 

7.1.1 while 무한루프의 구성

while(1)

{

printf("무한 루프\n");

}

 

 7.2 for문

     [예문]

#include <stdio.h>
int main()
{
  int iCnt;
  for(iCnt=0;3>iCnt;++iCnt) /* for(초기식;조건식;증감식) */
  {
    printf("test\n"); /* 반복의 문장 */
  }
  return 0;
}

[결과]