C
---FOR
goto
while
Do-while

break
while()
do
while()
goto
….…..
for
continue
6.5 for
Cforwhile
for
for(123)
(1) 1
(2) 2
a:(0)for(3)
b:(0)(5)
(3) 3
(4) (2)
(5) for
6.6for
6.6
for()
:
for(i=1;i<=100;i++)
sum=sum+i;
6.2
i=1;
while(i<=100)
{sum=sum+i;
i++;
}
for
1+3+5+…+201
main()
{
int i,sum;
i=1;
sum=0;
while( i<=201 )
{ sum+=i; i+=2; }
printf("sum is %d\n",sum);
}
main()
{
int i,sum=0;
for( i=1; i<=201 ; i+=2)
sum+=i;
printf("sum is %d",sum);
}
FOR
10035?
#include<stdio.h>
main()
{ int i,sum; i=1; sum=0;
while(i<100)
{ if(i%3==0&&i%5==0)
sum=sum+i;
i++; }
printf(“sum=%d\n”);
}
for
(1) for 1”for1
for(i<=100;i++) sum=sum+i; 1”
(2) 22
for(i=1; ;i++) sum=sum+i;
12
i=1;
while(1)
{sum=sum+1;
i++;}
(3) 3
4132
for(;i<=100;) while(i<=100)
{sum=sum+i; {sum=sum+i;
i++;} i++;}
whileforwhile
5,for( ; ; )
printf(“Go!Go!Go!\n”);
while(1)
(2)
(6) 1:
for (sum=0,i=1;i<=100;i++) sum=sum+i;
for
100073
main()
{
int n,i;
i=0;
for( n=1; n<=1000; n++)
if( n%7==0 && n%3!=0 )
i++;
printf("%d",i);
}
FOR
[1999]35
main()
{
int i,a,b,c,j=0;
for(i=1;i<=999;i++)
{
a=i%10;
b=i%100/10;
c=i/100;
if(i%3==0&&(a==5||b==5||c==5))
j++;
}
printf("%d",j) ;
}
6.6
(whiledo whilefor)
(1) while( )
{…
while( )
{…}
}
(2) do
{…
do
{… }
while( );
}
while( );
(3) for(;;)
{
for(; ;)
{…}
}
(4) while( )
{…
do
{…}
while( );

}
(5) for(; ;)
{…
while( )
{ }

}
(6) do
{

for (; ;)
{ }
}
while( );
main( )
{ int x,y;
for(x=1;x<=3;x++)
{ for(y=1;y<=3;y++)
printf("%2d",x*y);
printf("\n");
}
}
1 2 3
2 4 6
3 6 9
for (k=5;k;k--)
for(j=0;j<4;j++)
{…}
20
2481234681224248[10100]
24n=1n=2424nn24
main()
{ int x,i,y,num=0;
for(x=10; x<=100; x++)
{
if(x%y==0) num++;
}
printf("\n%d\n",num);
}
y=0;
for(i=1; i<=x; i++)
if(x%i==0) y++;
9 91*1=11*2=2 2*2=41*3=3 2*3=6 3*3=9
main()
{
int i,j;
for( j=1; j<=9; j++ )
for( i=1; i<=j ; i++ )
{
printf( "%d*%d=%-3d ",i,j,i*j) ;
if ( j==i ) printf ("\n") ;
}
}
6.8.2 continue
continue;
continuebreakcontinuebreak
(1) while(1)
{ …
if(2) break

}
(1)6.10(2)6.116.106.11 2”
(2) while(1)
{…
if(2) continue;

}
6.10 6.11
6.51002003
main()
{
int n;
for (n=100;n<=200;n++)
{if (n%3==0)
continue;
printf("%d"n);
}
}
n3continue(printf)n3printf
6.5
if (n%3!=0) printf("%d"n);
continuecontinue
breakcontinue
main( )
{
int j=1;
for( ; j<10; j++ )
{ if(j>5) break;
if(j%2!=0)
{j+=3;
continue;
}
j-=1;
}
printf ("%d\n",j);
}
9
For N!
#include <stdio.h>
main()
{
int n,i,t=1;
scanf(“%d”,&n);
for(i=1;i<=n;i++)
t=t*i;
printf(“n!=%d”,t);
}
50521
Result,146
main()
{
int a,b,c,i=0; /*a b c521*/
for(a=0;a<=10;a++)
for(b=0;b<=25;b++)
for(c=0;c<=50;c++)
if(c+2*b+5*a==50) i++;
printf("Result,%d\n",i);
getch();
}
6.8(m),m
:
m2m m2m ik(m)m2k(m)i1i=k+1ik+12k
#include <math.h>
main()
{
int mik;
scanf("%d"&m);
k=sqrt(m+1);
for (i=2;i<=k;i++)
if(m%i==0) break;
if(i>=k+1) printf("%d is a Prime mubern"m);
else printf("%d is not a Prime numbern"m);
}
6.9100200
main()
{
int mkin=0;
for(m=101;m<=200;m=m+2)
{
k=sqrt(m);
for (i=2;i<=k;i++)
if (m%i==0) break;
if (i>=k+1){printf("%d "m);n=n+1;}
if(n%10==0) printf("n");
}
printf ("n");
}
int prime(int x)
{
int i;
for(i=2;i<x;i++)
if(x%i==0) break;
if(i>=x) return 1;
else return 0;
}
6.8(m),m
int prime(int x)
{
int i;
for(i=2;i<x;i++)
if(x%i==0) break;
if(i>=x) return 1;
else return 0;
}
main()
{
int m;
scanf("%d",&m);
if(prime(m)==1)
printf("YES\n");
else
printf("NO\n");
}