SlideShare a Scribd company logo
1 of 60
4




1)             10

2)             28

3)             29
4)             32
5)             33
6)             34

7)             35
         6/2
1

2                            for

3                            while

4



    1.


    2.
    3.                               for , while ,

         do-while

    4.                               for , while ,

         do-while
    5.
         for , while , do-while
1.




1.1                 Increment Operator



      4.1



        ++   increment
                            1
b=3 ;

               a=b++




          1                        2       a=b;

    a=3

                              b=b+1;       b=3+

1

     2.          a     3       b       4


                           b=3 ;




          1.                       2

          b=b+1;             b=3+1

          a=b;             a=4

     2.          a     4      b        4
1.2                                decrement operator


 4.2



            --           decrement               1




       b=3

                      a = b- - ;




                 1.                            2

                 a=b;                   a=3

                 b=b-1;                  b=3-1

       2.                a          3     b          2




                  a=- -b ;




                 1.                            2
b=b-1;                b=3-1

             a=b;            a=2

2.            a       2       b         2




1.3                           (compound assignment

operators)



       4.3

             (sym                  (operat
      bol)                  ors)
       =              Assignment                    a=b
      +=                  Addition           a+=b         (a=a
                                                    +b)
      -=              Subtraction            a-=b         (a=a-
                                                    b)
      *=              Multiplication         a*=b         (a=a*
                                                    b)
      /=                  Division           a/=b         (a=a/
                                                    b)
      %=               Remainder             a%=b         (a=a
                                                    %b)
&=                         bitwise AND        a&=b          (a=a
                                                                  &b)
              |=                 bitwise Inclusive O a|=b                (a=a|
                                                 R                 b)
             ^=                 bitwise exclusive O a^=b                 (a=a^
                                                 R                 b)
            <<=                              right shift   a<<2          (a=a
                                                                  <<2)
            >>=                              left shift    a>>3          (a=a
                                                                  >>3)


1.4




                                   4.1
#include <stdio .h>
/* project_loop//operatorl.c */
main ( )
{
int a = 2 , = 4 ;
printf ( “---------------------- nn ”) ;
printf ( “ * operator *n ”) ;
printf ( “---------------------- nn”) ;
printf ( a = -> %d n “ , a ) ;


printf ( “ a = a + 1 -> %d nn ” , a ) ;
printf (“ b = -> %d n “ , b ) ;

  b+=1 ;

printf ( “ b + = 1 -> %d n ” , b ) ;
printf ( “---------------------- nn ”) ;
}
a=a+1;




     ----------------------------------------------------------------

     ------

        * Operator *

     ----------------------------------------------------------------

     ------

         a=                       --> 2

         a = a+1                  --> 3

         b=                       --> 4

         b + = 1 -->4.1
                     5                                         4.1
     ---------------------------------------------------------------- = 1 ;
                                               a=a+1;             a+
     ----

     Press any 4.2 to continue
               key



#include <stdio .h>
/* project_loop//operatorl.c */
main ( )
{
int a = 2 , = 4 ;
printf ( “---------------------- nn ”) ;
printf ( “ * operator *n ”) ;
printf ( “---------------------- nn”) ;
printf ( a = -> %d n “ , a ) ;
printf (“ b = -> %d n “ , b ) ;
printf (“ n “) ;




printf (“ a = b + + n “) ;
printf ( “ a = %d n ” , a ) ;
a = b ++ ;




      b = ++a ;




  ----------------------------------------------------------------------

      * Operator *

  ----------------------------------------------------------------------

      a=                  --> 2

      b=                  --> 4

       a = b ++

       a= 4

       b= 5

       b = a ++

       a= 5

       b= 5
                                    4.2                                            4.2
  --------------------------------------------------------------------
                       a = b ++ ;                                              2
  Press any key to continue

             a=b;                             b                            a

a=4



  --------------------------------------------------------------------
a=b+1 ;                            4+1             5

b           b=5

                         b = ++ a ;

              a=a+1;                                    a       4     4+1

a=5

              a=b+1 ;                            a                      b

a=5

      1.5




                              implicit type conversion




                                             explicit type conversion

                                   4.3


    #include <stdio . h >
    / * file name job6 */
    main ( )

    {

        Int value1 = 10 , result2 ; float value 2 = 3.17 , result ;

    Const char line * 40 + = “______________________________” ;
    printf ( “ % s nn “ , line) ;
    printf ( “ * Implicit type conversion * n “) ;
    printf ( “ % s nn “ , line) ;




    printf ( “ 10 + 3.17 = % . 2f nn “ , result1) ;
result 1 = value1 + value2 ;




 result 2 = (int) ( value1 + value2 ) ;




         -----------------------------------------------------------------------------------
         * Implicit type conversion *
         ----------------------------------------------------------------------------------
         10 + 3.17 =13.17
         10 / 3       = 3.00
         ----------------------------------------------------------------------------------
         * Explict type conversion *
         <int><10 + 3.17 >               = 13
         ----------------------------------------------------------------------------------
         Press any key to continue




                          4.3                                                                  4.3




1.                             result 1 = value1 + value 2 ;

                      10 + 3.17                     13.17

result 1
2.                           result 1 = value / 3 ;




                                                  /

                                                       % .2f



3.                           result 2 = (int) ( value1 + value2 ) ;

                            10 + 3.17       13.17                  int ()

                                                  13                     result 1

2                                     for

                        :




                                        3



                :                           for



2.1                                                                for

                                for
    For (           =           ;                 ;            )
 {
            statemmnt       (s) ;

 }
:        1                                                {}




                             4.1                                           for

2.2                              for

                                                       5



                         4.4

                                                                     for
#include <stdio . h>
/* project_loop // ex_for1.cpp */
main ( )
{
char name [ 30 ] ; int n ;
printf (“ Report Data n “ ) ;
Printf ( “ **************************************** nn “) ;
for ( n = 1 ; n < 6 ; n++ )
              {
          printf (“ No. => %d “ , n ) ;
          printf ( “ Name is = > “ ) ; scanf ( “ %s “ , name ) ;
             }




             Report Data
****************************************************
NO. =>1      Name is => ANAN      ANAN
NO. =>2      Name is => SOMJIT SOMJIT                                        5
NO. =>3      Name is => UILAI     UILAI
NO. =>4      Name is => RUNG      RUNG
NO. =>5      Name is => TEERA TEERA                                     For ( n =1 ; n < 6 ; n ++)
****************************************************

         End program ………………………….
Press any key to continue




                        4.4                                            4.4

                         1.                                        5



                2.                                                               n

                        1

                3.                  n           6


                4.                                                                             {}

      For ( n = 1 ; n < 6 ; n++)
      {

      Printf ( No . => %d , n ) ;
1                                                                     for   n

             1                6                            n = n+1




       2.3                                for




                                   4.5

                                            for


    #include <stdio .h >
    /* project_loop // ex_for2_1.cpp */
    main ( )
    {
    char name [ 30 ] ;

    int midterm , final ,score , n ,num ;
    printf ( “ key loop => “) ; scanf ( “%d” , &num) ;
    printf ( “ n Report Score n “ ) ;
    printf ( “ ***************************************** nn “ ) ;



       For ( n = 1 ; n <= num ; n++)
              {
       printf ( “ No. => %d “ , n)
       printf ( “ Name is => “ ) ; scanf ( “ %s” , name) ;
             }
    Printf( “ **************************************** n “ ) ;
Key loop => 3 3

       Report Score
****************************************************
NO. =>1       Name is => ANAN
                                  SOMKIT
NO. =>2       Name is => SOMJIT
                                  LINDA
NO. =>3       Name is => UILAI
                                  KITTI
****************************************************

         End program ………………………….
Press any key to continue
                                                                         for ( n = 1 ; n <num ; n++)




                      4.5                                                  4.5

                      1


              2.                            3                                      3

              3.   Printf ( “ key loop => “ ) ; scanf ( “ %d “ , num)
                   for ( n =1 ; n <= num ; n++)
                   {
                   printf ( “ No. => %d “ , n)
                   printf ( “ Name is => “ ) ; scanf ( “ %s” , name) ;
                     }
3.                                while

                              :


                                             while




                                                     {}

          while


     {}           while

            >




                                          while

                          while




            >                                {}
while

3.2   while




       while
Ctrl-Break



         n <= 5                n   n




    3.




while
while

                            while

n <= 5



                n = n+1 ;           n>5

         while n <= 5
while




        n
while   n
n

           num




       do-while




>




                  do – while

    do – while
do – while




do – while
do – while




             {}
while n <=

5

             n>5

     n++ :         n=n +1:           n

    n>5

                             {}




              do – while
do – while   n
5.

     5.1

                                                    for



           For                   pretest   loop      3

                                                     2

                                                     3


                                                    for


compound          statement                         for

                         while                      for


                                   for            while

                                             20


            for
n




     key loop =>……………
     Report Score
     ****************************
     No. => ……………
     name is =>    …………..
     midterm is => …………..
     Final is =>   ……………
     * Score =     ……………
     *****************************
      *Average Score is = ………….
     *****************************




1.

1.1

1.2
=   1

                 =

                     =


                     =

      1.3



1.4

1.5



                              num
                               n
                             name
                            midterm
                              final
                             score
                              sum
                            average



       1.6               action)
1                           (num)

2)                          for (n =1; n<=num ; n++)

                                     2.1-2.6

     3

     2.1)                 (n)

     2.2)                              (name)

     (midterm)

            (final)

     2.3)                           (score) = midterm + final

     2.4)         score

     2.5)                           (sum) = sum + score

     2.6)                       2

3)                    (average) = sum / num

4)       average

5)
2.


               start




                  num



     For (n = 1 ; n <= num ; n++)   n >num


                       n <= num

                       n                     Averge = sum / num




            name,midterm,final

                                                average



      Score = midterm + final                    end




                    score




         sum = sum + score
3.

     #include <stdio.h>
     /* file name ex_for3.cpp*/
     main ()
     {
     char name [30] ;
     int midterm = 0 , final = 0 , score = 0 ,n , num ;
     float sum = 0 , average = 0 ;
     printf (“ key loop => “) ; scanf (“%d “,&num) ;
     Printf (“n Report Score n”) ;
     printf(“*************************n n”) ;

     for(n = 1;n <= num ; n++)
          {
     printf (,“No. => %d n” , n) ;
     printf (“Name is => “) ;      scanf (“%s”,name) ;
     printf (“midterm is => “) ;      scanf (“%d”&midterm) ;
     printf (“final is => “) ;   scanf (“%d”&final) ;
          score = midterm =+ final;
     printf ( “* score = %dn”,score) ;
          sum = sum + score ;
     printf (“*****************n”) ;
           }

     average = sum / num ;
     printf (“* Averge score is = %.2f n” , averge) ;
     printf (“***********************n) ;

     }
3
1.



2.




3.
           for
                     2




 3
     for
5.2

                              while

     while                                 repetition

control      structure)                        loop)

                                                  for




                                               while




  endless                                      loop)




                    while




                                   -
                                       w
                            hile
while

while               statement ;   while



    {

           ;

           ;


                ;

}

        while




                       0


                            n
0




     Report Score
     ===========================
     Student Id => ……………                   0
     No. =>        …………….
     name is =>    …………..
     midterm is => …………..
     Final is =>   ……………
     * Score =     ……………
     ===========================
     *Average Score is = ………….
     ===========================




1.

1.1

1.2

                     =             1

                               =

                                       =
–1)

                   =

      1.3



1.4

1.5



                                  id
                                  n
                                name
                               midterm
                                 final
                                score
                                 sum
                               average



       1.6               action)

            1)    (n)              1

            2           (id)

            3)                 while (id ! = 0)

                                   3.1-3.8
4

     3.1)              (n)

     3.2)                        (name)

                 (midterm)

                    (final)

     3.3)                     (score) = midterm + final

     3.4)      score

     3.5)                     (sum) = sum + score

        3.6)           n

        3.7)                      id)

     3.8)

4)                  (average) = sum / (num-1)

5)     average

6)
2.
               start




             n =1



                  id



                               no
          While (id !=0)


                    yes

                       n            Averge = sum / num (n-1)




          name,midterm,final

                                         average



     Score = midterm + final               end




                  score




        sum = sum + score
n = n+1




                                     id




3.

     #include <stdio.h>
     /* file name ex_while4.c*/
     main ()
     {
     char name [30] ;
     int midterm = 0 , final = 0 , score = 0 ,n=1 , id ;
     float sum = 0 , average = 0 ;
     printf (“n Report Score n“) ;
     printf(“==========================n n”) ;
     Printf (“student id . => ”) ; scanf (“%d”,& id) ;

     while (id ! =0)
          {
     printf (,“No. => %d n” , n) ;
     printf (“Name is => “) ;       scanf (“%s”,name) ;
     printf (“midterm is => “) ;       scanf (“%d”&midterm) ;
     printf (“final is => “) ;   scanf (“%d”&final) ;
          score = midterm =+ final;
     printf ( “* score = %dn”,score) ;
          sum = sum + score ;
     printf (“============================n”) ;
     printf (“student id . => ”) ; scanf (“%d”,& id) ;
           }

     average = sum / (n-1) ;
     printf end job….. n” ,) ;
     printf (“======================n) ;
     printf (“* Averge score is = %.2f n” , averge) ;
     printf (“======================n) ;

     }
1.                                     (averge) =

     (sum)                (n)-1) ; n


                                                    n       3

             1                                      0

                                                        2

                         1

                                       =            /


2.               scanf (“%d”,& id) ;           2
Printf (“student id . => ”) ; scanf (“%d”,& id) ;
      while (id ! =0)
           {
      printf (,“No. => %d n” , n) ;
           ……….
      printf (“student id . => ”) ; scanf (“%d”,& id) ;
            }




                                    2                     while


           (id ! =0)




#include <stdio.h>

int counter , num;

char word[20] = "Bodindecha";
num             counter

                                  while

                         counter <= 11



    printf("ntcounter = %2d my school is %s print round %d.

",counter,word,++num);

        counter = counter + 2                       counter
counter                         counter <= 11




5.3

                            do-while

      do while                              loop)

                                  while




                                 do while




endless loop)



                 do while




                            -
do while
          Do {

                    ;

                    ;


                        ;

          }while                ;




       do while




#include <stdio.h>

intcounter ,num ;

char word[20] = "Bodindecha";
counter

                   do while             printf("ntcounter =

%2d my school is %s print round %d. ",counter,word,++num);

   counter = counter + 2;

   counter < 11
counter

                               /* example4_17.c */




            while




Report Score
===========================
No. =>          …………….
name is =>     …………..
midterm is => …………..
Final is =>    ……………
* Score =      ……………
===========================
calculate again y/n => ………….
===========================
*Average Score is = ………….                  y/n
===========================
1.

1.1

1.2

                  =   1

                      =

                          =

            –1)

                          =             +


                          =

      1.3

                  –



1.4

1.5



                               ans
                                n
                               name
                              midterm
final
                                 score
                                    sum
                              average



1.6                        action)

 1)                 (n)               1

 2)                            do

      2.1)                 (n)

      2.2)                                  (name)

                    (midterm)

                          (final)

      2.3)                           (score) = midterm + final

      2.4)         score

      2.5)                            (sum) = sum + score

            2.6)           n = n+1

            2.7)                                (ans)

      2.8)                     while (ans!=’n’)

                                      2

        3
3)             (average) = sum / (n-1)

4)   average

5)
start

2.
                       n =1




                        do




                             n



                name,midterm,final




           Score = midterm + final




                       score



            sum = sum + score




                 n = n+1



                      ans


     yes

               While (ans!=’n’)
Averge = sum / num (n-1)




                                                                average


3.
                                                                  end

     #include <stdio.h>
     /* file name ex_do5.c*/
     main ()
     {
     char ans ;
     char name [30] ;
     int midterm = 0 , final = 0 , score = 0 ,n=1 , id ;
     float sum = 0 , average = 0 ;
     printf (“n Report Score n“) ;
     printf(“==========================n n”) ;

     do {
     printf (“n”)
     printf (,“No. => %d n” , n) ;
     printf (“Name is => “) ;      scanf (“%s”,name) ;
     printf (“midterm is => “) ;      scanf (“%d”&midterm) ;
     printf (“final is => “) ;   scanf (“%d”&final) ;
           score = midterm =+ final;
     printf ( “* score = %dn”,score) ;
           sum = sum + score ;
            n = n+ 1
     printf (“============================n”) ;
     printf (“n calculate again y/n = > “ ) ;
     ans = getche ( ) ;
          } while (ans ! = “n”) ;

     average = sum / (n-1) ;
     printf (“n”,) ;
     printf (“======================n) ;
     printf (“* Averge score is = %.2f n” , averge) ;
     printf (“======================n) ;
     printf end job….. n” ,) ;


     }
1.
     do   {
          ……………………
     ans = getche ( ) ;
         } while (ans ! = “n”) ;




2.                           ans = getche ( )

     ;

     ans

3.                                   ans        }

     while (ans ! = “n”) ;

                                           n
3

for   while   do-while
for




     while




{}

{}




     do – while

                          {}

1


                  while
4



          “ ++ ”




2.




3.

for




      while
loop)




                     loop)      loop)

                        loop)     loop)

                     loop)         loop)




     while              for




             for




6.       “--”



                    2
a = 3 , b= 2                             7-8

7. a /=b ;                                  a

              (a=a/b)      a        1

              (a=a * b)         a       1

              (a=a-b)       a       1

              (a=a+ b)      a       5

8. a - =b ;                                   a

              (a=a/b)      a        1

              (a=a * b)         a       1

              (a=a-b)       a       1

              (a=a+ b)          a       5




9.                        for

     5         4

     2        3

10.                                     for
รายงานการเขียนคำสั่งควบคุมแบบวนซ้ำ กลุ่ม 4 ม. 6 ห้อง2

More Related Content

Viewers also liked

Private Client Presentation
Private Client PresentationPrivate Client Presentation
Private Client Presentationgibassetmgmt
 
Private Client Presentation
Private Client PresentationPrivate Client Presentation
Private Client Presentationgibassetmgmt
 
Digital music media
Digital music mediaDigital music media
Digital music mediamusic_hayes
 
Private Client Presentation
Private Client PresentationPrivate Client Presentation
Private Client Presentationgibassetmgmt
 
Block parties, break dancing and cultural background
Block parties, break dancing and cultural backgroundBlock parties, break dancing and cultural background
Block parties, break dancing and cultural backgroundmusic_hayes
 
การเขียนคำสั่งควบคุมแบบวนซ้ำ กลุ่ม 4 ม.6 ห้อง2
การเขียนคำสั่งควบคุมแบบวนซ้ำ กลุ่ม 4 ม.6 ห้อง2การเขียนคำสั่งควบคุมแบบวนซ้ำ กลุ่ม 4 ม.6 ห้อง2
การเขียนคำสั่งควบคุมแบบวนซ้ำ กลุ่ม 4 ม.6 ห้อง2Pookie Pook
 
Man in the mirror
Man in the mirrorMan in the mirror
Man in the mirrormusic_hayes
 
Y7 revision for 2014 exam
Y7 revision for 2014 exam Y7 revision for 2014 exam
Y7 revision for 2014 exam music_hayes
 
Private Client Presentation
Private Client PresentationPrivate Client Presentation
Private Client Presentationgibassetmgmt
 
Private Client Presentation
Private Client PresentationPrivate Client Presentation
Private Client Presentationgibassetmgmt
 
Year 9 exam revision 2014
Year 9 exam revision 2014Year 9 exam revision 2014
Year 9 exam revision 2014music_hayes
 
Old school hip hop
Old school hip hopOld school hip hop
Old school hip hopmusic_hayes
 
Automatic voltage regulator
Automatic voltage regulatorAutomatic voltage regulator
Automatic voltage regulatorJaja Kustija
 
Hayes School Music Tour: Spain 2014
Hayes School Music Tour: Spain 2014Hayes School Music Tour: Spain 2014
Hayes School Music Tour: Spain 2014music_hayes
 
The synthesizer for A2 music tech students
The synthesizer for A2 music tech studentsThe synthesizer for A2 music tech students
The synthesizer for A2 music tech studentsmusic_hayes
 

Viewers also liked (17)

Private Client Presentation
Private Client PresentationPrivate Client Presentation
Private Client Presentation
 
Private Client Presentation
Private Client PresentationPrivate Client Presentation
Private Client Presentation
 
Digital music media
Digital music mediaDigital music media
Digital music media
 
Private Client Presentation
Private Client PresentationPrivate Client Presentation
Private Client Presentation
 
Block parties, break dancing and cultural background
Block parties, break dancing and cultural backgroundBlock parties, break dancing and cultural background
Block parties, break dancing and cultural background
 
การเขียนคำสั่งควบคุมแบบวนซ้ำ กลุ่ม 4 ม.6 ห้อง2
การเขียนคำสั่งควบคุมแบบวนซ้ำ กลุ่ม 4 ม.6 ห้อง2การเขียนคำสั่งควบคุมแบบวนซ้ำ กลุ่ม 4 ม.6 ห้อง2
การเขียนคำสั่งควบคุมแบบวนซ้ำ กลุ่ม 4 ม.6 ห้อง2
 
Man in the mirror
Man in the mirrorMan in the mirror
Man in the mirror
 
Y7 revision for 2014 exam
Y7 revision for 2014 exam Y7 revision for 2014 exam
Y7 revision for 2014 exam
 
Private Client Presentation
Private Client PresentationPrivate Client Presentation
Private Client Presentation
 
Private Client Presentation
Private Client PresentationPrivate Client Presentation
Private Client Presentation
 
Year 9 exam revision 2014
Year 9 exam revision 2014Year 9 exam revision 2014
Year 9 exam revision 2014
 
Old school hip hop
Old school hip hopOld school hip hop
Old school hip hop
 
Y8 revision
Y8 revisionY8 revision
Y8 revision
 
Automatic voltage regulator
Automatic voltage regulatorAutomatic voltage regulator
Automatic voltage regulator
 
Pertemuan 1
Pertemuan 1Pertemuan 1
Pertemuan 1
 
Hayes School Music Tour: Spain 2014
Hayes School Music Tour: Spain 2014Hayes School Music Tour: Spain 2014
Hayes School Music Tour: Spain 2014
 
The synthesizer for A2 music tech students
The synthesizer for A2 music tech studentsThe synthesizer for A2 music tech students
The synthesizer for A2 music tech students
 

Similar to รายงานการเขียนคำสั่งควบคุมแบบวนซ้ำ กลุ่ม 4 ม. 6 ห้อง2

การเขียนคำสั่งควบคุมแบบวนซ้ำ กลุ่ม 4 ม.6 ห้อง2
การเขียนคำสั่งควบคุมแบบวนซ้ำ กลุ่ม 4 ม.6 ห้อง2การเขียนคำสั่งควบคุมแบบวนซ้ำ กลุ่ม 4 ม.6 ห้อง2
การเขียนคำสั่งควบคุมแบบวนซ้ำ กลุ่ม 4 ม.6 ห้อง2Pookie Pook
 
Ruby nooks & crannies
Ruby nooks & cranniesRuby nooks & crannies
Ruby nooks & cranniesKerry Buckley
 
Running Free with the Monads
Running Free with the MonadsRunning Free with the Monads
Running Free with the Monadskenbot
 
Inversematrixpptx 110418192746-phpapp014.7
Inversematrixpptx 110418192746-phpapp014.7Inversematrixpptx 110418192746-phpapp014.7
Inversematrixpptx 110418192746-phpapp014.7Kimguan Tan
 
Inverse matrix pptx
Inverse matrix pptxInverse matrix pptx
Inverse matrix pptxKimguan Tan
 
10b- Rabin Karp String Matching Problem.pptx
10b- Rabin Karp String Matching Problem.pptx10b- Rabin Karp String Matching Problem.pptx
10b- Rabin Karp String Matching Problem.pptxAOUNHAIDER7
 
Algebra cheat sheet
Algebra cheat sheetAlgebra cheat sheet
Algebra cheat sheetalex9803
 
From Javascript To Haskell
From Javascript To HaskellFrom Javascript To Haskell
From Javascript To Haskellujihisa
 
Approximate Matching (String Algorithms 2007)
Approximate Matching (String Algorithms 2007)Approximate Matching (String Algorithms 2007)
Approximate Matching (String Algorithms 2007)mailund
 
Lab Manual IV (1).pdf on C++ Programming practice
Lab Manual IV (1).pdf on C++ Programming practiceLab Manual IV (1).pdf on C++ Programming practice
Lab Manual IV (1).pdf on C++ Programming practiceranaibrahim453
 
Python PCEP Creating Simple Functions
Python PCEP Creating Simple FunctionsPython PCEP Creating Simple Functions
Python PCEP Creating Simple FunctionsIHTMINSTITUTE
 
The Properties of Mathematics
The Properties of MathematicsThe Properties of Mathematics
The Properties of Mathematicsarinedge
 

Similar to รายงานการเขียนคำสั่งควบคุมแบบวนซ้ำ กลุ่ม 4 ม. 6 ห้อง2 (20)

Fallacy
FallacyFallacy
Fallacy
 
การเขียนคำสั่งควบคุมแบบวนซ้ำ กลุ่ม 4 ม.6 ห้อง2
การเขียนคำสั่งควบคุมแบบวนซ้ำ กลุ่ม 4 ม.6 ห้อง2การเขียนคำสั่งควบคุมแบบวนซ้ำ กลุ่ม 4 ม.6 ห้อง2
การเขียนคำสั่งควบคุมแบบวนซ้ำ กลุ่ม 4 ม.6 ห้อง2
 
Ruby nooks & crannies
Ruby nooks & cranniesRuby nooks & crannies
Ruby nooks & crannies
 
Lec13
Lec13Lec13
Lec13
 
Running Free with the Monads
Running Free with the MonadsRunning Free with the Monads
Running Free with the Monads
 
Inversematrixpptx 110418192746-phpapp014.7
Inversematrixpptx 110418192746-phpapp014.7Inversematrixpptx 110418192746-phpapp014.7
Inversematrixpptx 110418192746-phpapp014.7
 
Inverse matrix pptx
Inverse matrix pptxInverse matrix pptx
Inverse matrix pptx
 
Python as a calculator
Python as a calculatorPython as a calculator
Python as a calculator
 
Hw1 sol
Hw1 solHw1 sol
Hw1 sol
 
Seminar fp
Seminar fpSeminar fp
Seminar fp
 
10b- Rabin Karp String Matching Problem.pptx
10b- Rabin Karp String Matching Problem.pptx10b- Rabin Karp String Matching Problem.pptx
10b- Rabin Karp String Matching Problem.pptx
 
Algebra cheat sheet
Algebra cheat sheetAlgebra cheat sheet
Algebra cheat sheet
 
From Javascript To Haskell
From Javascript To HaskellFrom Javascript To Haskell
From Javascript To Haskell
 
R vectorization
R vectorizationR vectorization
R vectorization
 
Approximate Matching (String Algorithms 2007)
Approximate Matching (String Algorithms 2007)Approximate Matching (String Algorithms 2007)
Approximate Matching (String Algorithms 2007)
 
ppt1s.pptx
ppt1s.pptxppt1s.pptx
ppt1s.pptx
 
Lab Manual IV (1).pdf on C++ Programming practice
Lab Manual IV (1).pdf on C++ Programming practiceLab Manual IV (1).pdf on C++ Programming practice
Lab Manual IV (1).pdf on C++ Programming practice
 
Python PCEP Creating Simple Functions
Python PCEP Creating Simple FunctionsPython PCEP Creating Simple Functions
Python PCEP Creating Simple Functions
 
matrices
matricesmatrices
matrices
 
The Properties of Mathematics
The Properties of MathematicsThe Properties of Mathematics
The Properties of Mathematics
 

Recently uploaded

Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...FIDO Alliance
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...FIDO Alliance
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfFIDO Alliance
 
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Skynet Technologies
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data SciencePaolo Missier
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxFIDO Alliance
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераMark Opanasiuk
 
Using IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandUsing IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandIES VE
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...panagenda
 
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Paige Cruz
 
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxFIDO Alliance
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...FIDO Alliance
 
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdfMuhammad Subhan
 
TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024Stephen Perrenod
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightSafe Software
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfSrushith Repakula
 
Generative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfGenerative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfalexjohnson7307
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxFIDO Alliance
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGDSC PJATK
 

Recently uploaded (20)

Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
 
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptx
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджера
 
Using IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandUsing IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & Ireland
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
 
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
 
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
 
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
 
TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
Generative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfGenerative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdf
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptx
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 

รายงานการเขียนคำสั่งควบคุมแบบวนซ้ำ กลุ่ม 4 ม. 6 ห้อง2

  • 1. 4 1) 10 2) 28 3) 29 4) 32 5) 33 6) 34 7) 35 6/2
  • 2. 1 2 for 3 while 4 1. 2. 3. for , while , do-while 4. for , while , do-while 5. for , while , do-while
  • 3. 1. 1.1 Increment Operator 4.1 ++ increment 1
  • 4. b=3 ; a=b++ 1 2 a=b; a=3 b=b+1; b=3+ 1 2. a 3 b 4 b=3 ; 1. 2 b=b+1; b=3+1 a=b; a=4 2. a 4 b 4
  • 5. 1.2 decrement operator 4.2 -- decrement 1 b=3 a = b- - ; 1. 2 a=b; a=3 b=b-1; b=3-1 2. a 3 b 2 a=- -b ; 1. 2
  • 6. b=b-1; b=3-1 a=b; a=2 2. a 2 b 2 1.3 (compound assignment operators) 4.3 (sym (operat bol) ors) = Assignment a=b += Addition a+=b (a=a +b) -= Subtraction a-=b (a=a- b) *= Multiplication a*=b (a=a* b) /= Division a/=b (a=a/ b) %= Remainder a%=b (a=a %b)
  • 7. &= bitwise AND a&=b (a=a &b) |= bitwise Inclusive O a|=b (a=a| R b) ^= bitwise exclusive O a^=b (a=a^ R b) <<= right shift a<<2 (a=a <<2) >>= left shift a>>3 (a=a >>3) 1.4 4.1 #include <stdio .h> /* project_loop//operatorl.c */ main ( ) { int a = 2 , = 4 ; printf ( “---------------------- nn ”) ; printf ( “ * operator *n ”) ; printf ( “---------------------- nn”) ; printf ( a = -> %d n “ , a ) ; printf ( “ a = a + 1 -> %d nn ” , a ) ; printf (“ b = -> %d n “ , b ) ; b+=1 ; printf ( “ b + = 1 -> %d n ” , b ) ; printf ( “---------------------- nn ”) ; }
  • 8. a=a+1; ---------------------------------------------------------------- ------ * Operator * ---------------------------------------------------------------- ------ a= --> 2 a = a+1 --> 3 b= --> 4 b + = 1 -->4.1 5 4.1 ---------------------------------------------------------------- = 1 ; a=a+1; a+ ---- Press any 4.2 to continue key #include <stdio .h> /* project_loop//operatorl.c */ main ( ) { int a = 2 , = 4 ; printf ( “---------------------- nn ”) ; printf ( “ * operator *n ”) ; printf ( “---------------------- nn”) ; printf ( a = -> %d n “ , a ) ; printf (“ b = -> %d n “ , b ) ; printf (“ n “) ; printf (“ a = b + + n “) ; printf ( “ a = %d n ” , a ) ;
  • 9. a = b ++ ; b = ++a ; ---------------------------------------------------------------------- * Operator * ---------------------------------------------------------------------- a= --> 2 b= --> 4 a = b ++ a= 4 b= 5 b = a ++ a= 5 b= 5 4.2 4.2 -------------------------------------------------------------------- a = b ++ ; 2 Press any key to continue a=b; b a a=4 --------------------------------------------------------------------
  • 10. a=b+1 ; 4+1 5 b b=5 b = ++ a ; a=a+1; a 4 4+1 a=5 a=b+1 ; a b a=5 1.5 implicit type conversion explicit type conversion 4.3 #include <stdio . h > / * file name job6 */ main ( ) { Int value1 = 10 , result2 ; float value 2 = 3.17 , result ; Const char line * 40 + = “______________________________” ; printf ( “ % s nn “ , line) ; printf ( “ * Implicit type conversion * n “) ; printf ( “ % s nn “ , line) ; printf ( “ 10 + 3.17 = % . 2f nn “ , result1) ;
  • 11. result 1 = value1 + value2 ; result 2 = (int) ( value1 + value2 ) ; ----------------------------------------------------------------------------------- * Implicit type conversion * ---------------------------------------------------------------------------------- 10 + 3.17 =13.17 10 / 3 = 3.00 ---------------------------------------------------------------------------------- * Explict type conversion * <int><10 + 3.17 > = 13 ---------------------------------------------------------------------------------- Press any key to continue 4.3 4.3 1. result 1 = value1 + value 2 ; 10 + 3.17 13.17 result 1
  • 12. 2. result 1 = value / 3 ; / % .2f 3. result 2 = (int) ( value1 + value2 ) ; 10 + 3.17 13.17 int () 13 result 1 2 for : 3 : for 2.1 for for For ( = ; ; ) { statemmnt (s) ; }
  • 13. : 1 {} 4.1 for 2.2 for 5 4.4 for #include <stdio . h> /* project_loop // ex_for1.cpp */ main ( ) { char name [ 30 ] ; int n ; printf (“ Report Data n “ ) ; Printf ( “ **************************************** nn “) ;
  • 14. for ( n = 1 ; n < 6 ; n++ ) { printf (“ No. => %d “ , n ) ; printf ( “ Name is = > “ ) ; scanf ( “ %s “ , name ) ; } Report Data **************************************************** NO. =>1 Name is => ANAN ANAN NO. =>2 Name is => SOMJIT SOMJIT 5 NO. =>3 Name is => UILAI UILAI NO. =>4 Name is => RUNG RUNG NO. =>5 Name is => TEERA TEERA For ( n =1 ; n < 6 ; n ++) **************************************************** End program …………………………. Press any key to continue 4.4 4.4 1. 5 2. n 1 3. n 6 4. {} For ( n = 1 ; n < 6 ; n++) { Printf ( No . => %d , n ) ;
  • 15. 1 for n 1 6 n = n+1 2.3 for 4.5 for #include <stdio .h > /* project_loop // ex_for2_1.cpp */ main ( ) { char name [ 30 ] ; int midterm , final ,score , n ,num ; printf ( “ key loop => “) ; scanf ( “%d” , &num) ; printf ( “ n Report Score n “ ) ; printf ( “ ***************************************** nn “ ) ; For ( n = 1 ; n <= num ; n++) { printf ( “ No. => %d “ , n) printf ( “ Name is => “ ) ; scanf ( “ %s” , name) ; } Printf( “ **************************************** n “ ) ;
  • 16. Key loop => 3 3 Report Score **************************************************** NO. =>1 Name is => ANAN SOMKIT NO. =>2 Name is => SOMJIT LINDA NO. =>3 Name is => UILAI KITTI **************************************************** End program …………………………. Press any key to continue for ( n = 1 ; n <num ; n++) 4.5 4.5 1 2. 3 3 3. Printf ( “ key loop => “ ) ; scanf ( “ %d “ , num) for ( n =1 ; n <= num ; n++) { printf ( “ No. => %d “ , n) printf ( “ Name is => “ ) ; scanf ( “ %s” , name) ; }
  • 17. 3. while : while {} while {} while > while while > {}
  • 18. while 3.2 while while
  • 19. Ctrl-Break n <= 5 n n 3. while
  • 20. while while n <= 5 n = n+1 ; n>5 while n <= 5
  • 21. while n
  • 22. while n
  • 23. n num do-while > do – while do – while
  • 24. do – while do – while
  • 26. while n <= 5 n>5 n++ : n=n +1: n n>5 {} do – while
  • 28. 5. 5.1 for For pretest loop 3 2 3 for compound statement for while for for while 20 for
  • 29. n key loop =>…………… Report Score **************************** No. => …………… name is => ………….. midterm is => ………….. Final is => …………… * Score = …………… ***************************** *Average Score is = …………. ***************************** 1. 1.1 1.2
  • 30. = 1 = = = 1.3 1.4 1.5 num n name midterm final score sum average 1.6 action)
  • 31. 1 (num) 2) for (n =1; n<=num ; n++) 2.1-2.6 3 2.1) (n) 2.2) (name) (midterm) (final) 2.3) (score) = midterm + final 2.4) score 2.5) (sum) = sum + score 2.6) 2 3) (average) = sum / num 4) average 5)
  • 32. 2. start num For (n = 1 ; n <= num ; n++) n >num n <= num n Averge = sum / num name,midterm,final average Score = midterm + final end score sum = sum + score
  • 33. 3. #include <stdio.h> /* file name ex_for3.cpp*/ main () { char name [30] ; int midterm = 0 , final = 0 , score = 0 ,n , num ; float sum = 0 , average = 0 ; printf (“ key loop => “) ; scanf (“%d “,&num) ; Printf (“n Report Score n”) ; printf(“*************************n n”) ; for(n = 1;n <= num ; n++) { printf (,“No. => %d n” , n) ; printf (“Name is => “) ; scanf (“%s”,name) ; printf (“midterm is => “) ; scanf (“%d”&midterm) ; printf (“final is => “) ; scanf (“%d”&final) ; score = midterm =+ final; printf ( “* score = %dn”,score) ; sum = sum + score ; printf (“*****************n”) ; } average = sum / num ; printf (“* Averge score is = %.2f n” , averge) ; printf (“***********************n) ; }
  • 34. 3 1. 2. 3. for 2 3 for
  • 35. 5.2 while while repetition control structure) loop) for while endless loop) while - w hile
  • 36. while while statement ; while { ; ; ; } while 0 n
  • 37. 0 Report Score =========================== Student Id => …………… 0 No. => ……………. name is => ………….. midterm is => ………….. Final is => …………… * Score = …………… =========================== *Average Score is = …………. =========================== 1. 1.1 1.2 = 1 = =
  • 38. –1) = 1.3 1.4 1.5 id n name midterm final score sum average 1.6 action) 1) (n) 1 2 (id) 3) while (id ! = 0) 3.1-3.8
  • 39. 4 3.1) (n) 3.2) (name) (midterm) (final) 3.3) (score) = midterm + final 3.4) score 3.5) (sum) = sum + score 3.6) n 3.7) id) 3.8) 4) (average) = sum / (num-1) 5) average 6)
  • 40. 2. start n =1 id no While (id !=0) yes n Averge = sum / num (n-1) name,midterm,final average Score = midterm + final end score sum = sum + score
  • 41. n = n+1 id 3. #include <stdio.h> /* file name ex_while4.c*/ main () { char name [30] ; int midterm = 0 , final = 0 , score = 0 ,n=1 , id ; float sum = 0 , average = 0 ; printf (“n Report Score n“) ; printf(“==========================n n”) ; Printf (“student id . => ”) ; scanf (“%d”,& id) ; while (id ! =0) { printf (,“No. => %d n” , n) ; printf (“Name is => “) ; scanf (“%s”,name) ; printf (“midterm is => “) ; scanf (“%d”&midterm) ; printf (“final is => “) ; scanf (“%d”&final) ; score = midterm =+ final; printf ( “* score = %dn”,score) ; sum = sum + score ; printf (“============================n”) ; printf (“student id . => ”) ; scanf (“%d”,& id) ; } average = sum / (n-1) ; printf end job….. n” ,) ; printf (“======================n) ; printf (“* Averge score is = %.2f n” , averge) ; printf (“======================n) ; }
  • 42. 1. (averge) = (sum) (n)-1) ; n n 3 1 0 2 1 = / 2. scanf (“%d”,& id) ; 2
  • 43. Printf (“student id . => ”) ; scanf (“%d”,& id) ; while (id ! =0) { printf (,“No. => %d n” , n) ; ………. printf (“student id . => ”) ; scanf (“%d”,& id) ; } 2 while (id ! =0) #include <stdio.h> int counter , num; char word[20] = "Bodindecha";
  • 44. num counter while counter <= 11 printf("ntcounter = %2d my school is %s print round %d. ",counter,word,++num); counter = counter + 2 counter
  • 45. counter counter <= 11 5.3 do-while do while loop) while do while endless loop) do while -
  • 46. do while Do { ; ; ; }while ; do while #include <stdio.h> intcounter ,num ; char word[20] = "Bodindecha";
  • 47. counter do while printf("ntcounter = %2d my school is %s print round %d. ",counter,word,++num); counter = counter + 2; counter < 11
  • 48. counter /* example4_17.c */ while Report Score =========================== No. => ……………. name is => ………….. midterm is => ………….. Final is => …………… * Score = …………… =========================== calculate again y/n => …………. =========================== *Average Score is = …………. y/n ===========================
  • 49. 1. 1.1 1.2 = 1 = = –1) = + = 1.3 – 1.4 1.5 ans n name midterm
  • 50. final score sum average 1.6 action) 1) (n) 1 2) do 2.1) (n) 2.2) (name) (midterm) (final) 2.3) (score) = midterm + final 2.4) score 2.5) (sum) = sum + score 2.6) n = n+1 2.7) (ans) 2.8) while (ans!=’n’) 2 3
  • 51. 3) (average) = sum / (n-1) 4) average 5)
  • 52. start 2. n =1 do n name,midterm,final Score = midterm + final score sum = sum + score n = n+1 ans yes While (ans!=’n’)
  • 53. Averge = sum / num (n-1) average 3. end #include <stdio.h> /* file name ex_do5.c*/ main () { char ans ; char name [30] ; int midterm = 0 , final = 0 , score = 0 ,n=1 , id ; float sum = 0 , average = 0 ; printf (“n Report Score n“) ; printf(“==========================n n”) ; do { printf (“n”) printf (,“No. => %d n” , n) ; printf (“Name is => “) ; scanf (“%s”,name) ; printf (“midterm is => “) ; scanf (“%d”&midterm) ; printf (“final is => “) ; scanf (“%d”&final) ; score = midterm =+ final; printf ( “* score = %dn”,score) ; sum = sum + score ; n = n+ 1 printf (“============================n”) ; printf (“n calculate again y/n = > “ ) ; ans = getche ( ) ; } while (ans ! = “n”) ; average = sum / (n-1) ; printf (“n”,) ; printf (“======================n) ; printf (“* Averge score is = %.2f n” , averge) ; printf (“======================n) ; printf end job….. n” ,) ; }
  • 54. 1. do { …………………… ans = getche ( ) ; } while (ans ! = “n”) ; 2. ans = getche ( ) ; ans 3. ans } while (ans ! = “n”) ; n
  • 55. 3 for while do-while
  • 56. for while {} {} do – while {} 1 while
  • 57. 4 “ ++ ” 2. 3. for while
  • 58. loop) loop) loop) loop) loop) loop) loop) while for for 6. “--” 2
  • 59. a = 3 , b= 2 7-8 7. a /=b ; a (a=a/b) a 1 (a=a * b) a 1 (a=a-b) a 1 (a=a+ b) a 5 8. a - =b ; a (a=a/b) a 1 (a=a * b) a 1 (a=a-b) a 1 (a=a+ b) a 5 9. for 5 4 2 3 10. for