ǹٻ(for , while , do...while)

for
while
do...while
Ẻ֡Ѵͧ "¹¤ for"
Ẻ֡Ѵͧ "¹¤ while "
Ẻ֡Ѵͧ "¹¤ do...while "
Ẻ֡Ѵͧ "¹¤ǹ"

ٻẺ ǹٻ(ǹͺ)
          ǹٻըشʧǹӧҹͧ͡觫仫ҵӹǹͺͧ ǹӧҹ͹䢷˹稨֧öش͡ҡٻͧ觹
          觷Ѻǹٻ C 3 觴¡ѹ for , while Ф do...while

for

        繤觷㹡äǺԴաǹͺ ͺ

ٻẺ
          for ( ; ͹ ; ҵ÷¹)

çҧ÷ӧҹͧǹٻ for

 

ҧ 1

#include<stdio.h>
#include<conio.h>
main()
{
   int i;
   for(i= 1;i< 10;i++)
   printf(" %d",i);
   getch();
}

                                    Ѿ

 

ҧ 2

#include<stdio.h>
#include<conio.h>
main()
{
   int i,j;
   for(i=1;i<5;i++)
     {
     for(j=i;j<5;j++)

        {
        printf(".");
        }

     printf("*\n");
     }

getch();
}

                                    Ѿ

 

while

ٻẺ

ǹͺẺ while 鹷ӧҹҡõǨͺ͹ 繨ԧзӧҹ觢ͧ while ǡǹѺ仵Ǩͺ͹ ͹䢨稨֧ش͡ҡ÷ӧҹ

ἹҾʴ÷ӧҹͧǹͺẺ while

ҧ while
#include<stdio.h>
#include<conio.h>
int i= 1 ;
main()
{
    while(i<= 10)
     {
     printf("%d\t",i);
     i++;
     }
getch();
}

Ţͧ

do...while

ǹͺẺ dowhile ҹ¡ѺǹͺẺ while ٻẺ¡ҹѧ

ǹͺẺ dowhile зӧҹ觢ͧ do ͹˹ͺ Ǩ֧Ǩͺ͹䢷 while 繤á ¶͹繨ԧǹѺ价ӧҹա ǡѺҵǨͺ͹ ҧ仨ҼšõǨͺ͹䢨͡ ֧ԡ÷ӧҹͧǹͺ dowhile
ἹҾʴ÷ӧҹͧ dowhile


ҧ dowhile
#include<stdio.h>
#include<conio.h>
int num=10;
main()
{
     do
     {
     printf("%d\t",num);
     num--;
     }
     while(num>=1);
getch();
}

Ţͧ

ͧ¹ num 13 Ŵѧ

˵ ҹǹͺẺ dowhile зӧҹǹͺ dowhile ҧ ˹觤駡͹еǨͺ͹ 觶Ҽ͡稡稺÷ӧҹ 㹢зǹͺẺ while ͹稵áա÷ӧҹ觢ͧǹͺ while Դ