SlideShare a Scribd company logo
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
b=3 ;
            a=++b
                1.                           2             b=b
+1;                  b=3+1
                                      a=b;               a=4
      2.              a        4      b          4

           --             decrement                  1


1.2                                decrement operator

      4.2
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
1.3
          (compound assignment
operators) 4.3
1.4
a = b ++ ;
      2
          a=b;                b       a
a=4
          a=b+1 ;       4+1       5
          b   b=5
             b = ++ a ;
          a=a+1;          a       4   4+1
1.5



                           implicit type
conversion




explicit type conversion
4.3
4.3                           4.3
1.                    result 1 = value1 + value 2 ;
                   10 + 3.17      13.17
result 1


2.                   result 1 = value / 3 ;

                                    /
           % .2f
2                               for
                        :



3

                    :                   for
      For (        =                ;   ;
2.1                )
      {
for           statemmnt       (s)   ;
      }                 for


              :     1
4.1             for

2.2         for

                  5
4.4
      for
1.               5

2.                        n
          1
3.            n   6

4.
2.3     for




        4.5
      for
4.5
4.5


1

2.      3   3
3.
3.
 while
                 :


         while




         {}      while

                 {}      while
while
         while


     >
{}
3.2           while




      while
Ctrl-
Break

             n <= 5
        n   n
while




          while
          while
n <= 5

                  n = n+1 ;
while



        n



while           n
n
num
do-while
do – while
             do – while




                          do – whil
do – while




do – while
{
}

      while n <= 5

n>5
           n++ :      n=n +1:
            n        n>5
{
}




    do – while
do – while   n
•        for
•        while
•        do-
    while
For
for

      2



          3   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.5




       num

        n

       name

      midterm
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
start

2.
                 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) ;

     }
while
                for



                      while



endless loop)
while
while
     while       statement ;
    while
{
         ;
         ;

             ;
}
         while
#include <stdio.h>
int counter , num;
char word[20] = "Bodindecha";
main()
{
    num = 0;
    counter = 3;
    while ( counter <= 11)
{
     printf("ntcounter = %2d my school is %s print
round %d. ",counter,word,++num);
    counter = counter + 2 ;
       }
getch();

}
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
do-while
     do while
 loop)
while


                do       while


                     endless loop)
do while
do while


Do {
          ;
          ;

              ;
} while           ;
#include <stdio.h>
int counter ,num ;
char word[20] = "Bodindecha";
main()
{
 Num = 0;
counter = 3;
do                                                  /*
start do while */
{
    printf("ntcounter = %2d my school is %s print
round %d. ",counter,word,++num);
    counter = counter + 2 ;
     } while (counter < 11 );                        /*
end do while */
getch();
}
/* end main() */
counter
                                        do while

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


counter < 11

                                       counter
for
while



{}
             {}
do -while

        {}1



while
10
      28
       29
       32
      33
      34
      35
6/2

More Related Content

Viewers also liked

Private Client Presentation
Private Client PresentationPrivate Client Presentation
Private Client Presentation
gibassetmgmt
 
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
music_hayes
 
Private Client Presentation
Private Client PresentationPrivate Client Presentation
Private Client Presentation
gibassetmgmt
 
Private Client Presentation
Private Client PresentationPrivate Client Presentation
Private Client Presentation
gibassetmgmt
 
Private Client Presentation
Private Client PresentationPrivate Client Presentation
Private Client Presentation
gibassetmgmt
 
Digital music media
Digital music mediaDigital music media
Digital music media
music_hayes
 

Viewers also liked (6)

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
 
Private Client Presentation
Private Client PresentationPrivate Client Presentation
Private Client Presentation
 
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
 

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

รายงานการเขียนคำสั่งควบคุมแบบวนซ้ำ กลุ่ม 4 ม. 6 ห้อง2
รายงานการเขียนคำสั่งควบคุมแบบวนซ้ำ กลุ่ม 4 ม. 6 ห้อง2รายงานการเขียนคำสั่งควบคุมแบบวนซ้ำ กลุ่ม 4 ม. 6 ห้อง2
รายงานการเขียนคำสั่งควบคุมแบบวนซ้ำ กลุ่ม 4 ม. 6 ห้อง2
Pookie Pook
 
8 arrays and pointers
8  arrays and pointers8  arrays and pointers
8 arrays and pointers
MomenMostafa
 
C++ Programm.pptx
C++ Programm.pptxC++ Programm.pptx
C++ Programm.pptx
Åįjâž Ali
 
Cpl
CplCpl
halstead software science measures
halstead software science measureshalstead software science measures
halstead software science measures
Deepti Pillai
 
901131 examples
901131 examples901131 examples
901131 examples
Jeninä Juco III
 
verilog code
verilog codeverilog code
verilog code
Mantra VLSI
 
C-LOOP-Session-2.pptx
C-LOOP-Session-2.pptxC-LOOP-Session-2.pptx
C-LOOP-Session-2.pptx
Sarkunavathi Aribal
 
21221
2122121221
21221
inKFUPM
 
Solucionario_de_Chapra_y_Canale_Quinta_E.pdf
Solucionario_de_Chapra_y_Canale_Quinta_E.pdfSolucionario_de_Chapra_y_Canale_Quinta_E.pdf
Solucionario_de_Chapra_y_Canale_Quinta_E.pdf
JeancarlosPatalasanc
 
Looping
LoopingLooping
Infix prefix postfix
Infix prefix postfixInfix prefix postfix
Infix prefix postfix
Self-Employed
 
Assignment 3
Assignment 3Assignment 3
Assignment 3
Ayesha Bhatti
 
PROGRAMMING IN C EXAMPLE PROGRAMS FOR NEW LEARNERS - SARASWATHI RAMALINGAM
PROGRAMMING IN C EXAMPLE PROGRAMS FOR NEW LEARNERS  - SARASWATHI RAMALINGAMPROGRAMMING IN C EXAMPLE PROGRAMS FOR NEW LEARNERS  - SARASWATHI RAMALINGAM
PROGRAMMING IN C EXAMPLE PROGRAMS FOR NEW LEARNERS - SARASWATHI RAMALINGAM
SaraswathiRamalingam
 
Introducing to Asynchronous Programming
Introducing to Asynchronous  ProgrammingIntroducing to Asynchronous  Programming
Introducing to Asynchronous Programming
Александр Федоров
 
Recursion in C
Recursion in CRecursion in C
Recursion in C
Lakshmi Sarvani Videla
 
12 lec 12 loop
12 lec 12 loop 12 lec 12 loop
12 lec 12 loop
kapil078
 
Simple C programs
Simple C programsSimple C programs
Simple C programs
ab11cs001
 
An efficient algorithm for the computation of Bernoulli numbers
 An efficient algorithm for the computation of Bernoulli numbers An efficient algorithm for the computation of Bernoulli numbers
An efficient algorithm for the computation of Bernoulli numbers
XequeMateShannon
 
All I Needed for Functional Programming I Learned in High School Algebra
All I Needed for Functional Programming I Learned in High School AlgebraAll I Needed for Functional Programming I Learned in High School Algebra
All I Needed for Functional Programming I Learned in High School Algebra
Eric Normand
 

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

รายงานการเขียนคำสั่งควบคุมแบบวนซ้ำ กลุ่ม 4 ม. 6 ห้อง2
รายงานการเขียนคำสั่งควบคุมแบบวนซ้ำ กลุ่ม 4 ม. 6 ห้อง2รายงานการเขียนคำสั่งควบคุมแบบวนซ้ำ กลุ่ม 4 ม. 6 ห้อง2
รายงานการเขียนคำสั่งควบคุมแบบวนซ้ำ กลุ่ม 4 ม. 6 ห้อง2
 
8 arrays and pointers
8  arrays and pointers8  arrays and pointers
8 arrays and pointers
 
C++ Programm.pptx
C++ Programm.pptxC++ Programm.pptx
C++ Programm.pptx
 
Cpl
CplCpl
Cpl
 
halstead software science measures
halstead software science measureshalstead software science measures
halstead software science measures
 
901131 examples
901131 examples901131 examples
901131 examples
 
verilog code
verilog codeverilog code
verilog code
 
C-LOOP-Session-2.pptx
C-LOOP-Session-2.pptxC-LOOP-Session-2.pptx
C-LOOP-Session-2.pptx
 
21221
2122121221
21221
 
Solucionario_de_Chapra_y_Canale_Quinta_E.pdf
Solucionario_de_Chapra_y_Canale_Quinta_E.pdfSolucionario_de_Chapra_y_Canale_Quinta_E.pdf
Solucionario_de_Chapra_y_Canale_Quinta_E.pdf
 
Looping
LoopingLooping
Looping
 
Infix prefix postfix
Infix prefix postfixInfix prefix postfix
Infix prefix postfix
 
Assignment 3
Assignment 3Assignment 3
Assignment 3
 
PROGRAMMING IN C EXAMPLE PROGRAMS FOR NEW LEARNERS - SARASWATHI RAMALINGAM
PROGRAMMING IN C EXAMPLE PROGRAMS FOR NEW LEARNERS  - SARASWATHI RAMALINGAMPROGRAMMING IN C EXAMPLE PROGRAMS FOR NEW LEARNERS  - SARASWATHI RAMALINGAM
PROGRAMMING IN C EXAMPLE PROGRAMS FOR NEW LEARNERS - SARASWATHI RAMALINGAM
 
Introducing to Asynchronous Programming
Introducing to Asynchronous  ProgrammingIntroducing to Asynchronous  Programming
Introducing to Asynchronous Programming
 
Recursion in C
Recursion in CRecursion in C
Recursion in C
 
12 lec 12 loop
12 lec 12 loop 12 lec 12 loop
12 lec 12 loop
 
Simple C programs
Simple C programsSimple C programs
Simple C programs
 
An efficient algorithm for the computation of Bernoulli numbers
 An efficient algorithm for the computation of Bernoulli numbers An efficient algorithm for the computation of Bernoulli numbers
An efficient algorithm for the computation of Bernoulli numbers
 
All I Needed for Functional Programming I Learned in High School Algebra
All I Needed for Functional Programming I Learned in High School AlgebraAll I Needed for Functional Programming I Learned in High School Algebra
All I Needed for Functional Programming I Learned in High School Algebra
 

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

  • 1. 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. b=3 ; a=++b 1. 2 b=b +1; b=3+1 a=b; a=4 2. a 4 b 4 -- decrement 1 1.2 decrement operator 4.2
  • 3. 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
  • 4. 1.3 (compound assignment operators) 4.3
  • 5. 1.4
  • 6. a = b ++ ; 2 a=b; b a a=4 a=b+1 ; 4+1 5 b b=5 b = ++ a ; a=a+1; a 4 4+1
  • 7. 1.5 implicit type conversion explicit type conversion
  • 8. 4.3
  • 9. 4.3 4.3 1. result 1 = value1 + value 2 ; 10 + 3.17 13.17 result 1 2. result 1 = value / 3 ; / % .2f
  • 10. 2 for : 3 : for For ( = ; ; 2.1 ) { for statemmnt (s) ; } for : 1
  • 11. 4.1 for 2.2 for 5
  • 12. 4.4 for
  • 13. 1. 5 2. n 1 3. n 6 4.
  • 14. 2.3 for 4.5 for
  • 15. 4.5 4.5 1 2. 3 3 3.
  • 16. 3. while : while {} while {} while
  • 17. while while > {}
  • 18. 3.2 while while
  • 19. Ctrl- Break n <= 5 n n
  • 20. while while while n <= 5 n = n+1 ;
  • 21.
  • 22. while n while n
  • 23. n num
  • 25. do – while do – while do – whil
  • 26. do – while do – while
  • 27. { } while n <= 5 n>5 n++ : n=n +1: n n>5
  • 28. { } do – while
  • 30. for • while • do- while
  • 31. For for 2 3 for
  • 32. n key loop =>…………… Report Score **************************** No. => …………… name is => ………….. midterm is => ………….. Final is => …………… * Score = …………… ***************************** *Average Score is = …………. *****************************
  • 33. 1. 1.1 1.2 = 1 = = = 1.3
  • 34. 1.5 num n name midterm
  • 35. 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
  • 36. start 2. 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
  • 37. 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) ; }
  • 38.
  • 39. while for while endless loop)
  • 40. while
  • 41. while while statement ; while { ; ; ; } while
  • 42. #include <stdio.h> int counter , num; char word[20] = "Bodindecha"; main() { num = 0; counter = 3; while ( counter <= 11) { printf("ntcounter = %2d my school is %s print round %d. ",counter,word,++num); counter = counter + 2 ; } getch(); }
  • 43. 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
  • 44.
  • 45. do-while do while loop) while do while endless loop)
  • 47. do while Do { ; ; ; } while ;
  • 48. #include <stdio.h> int counter ,num ; char word[20] = "Bodindecha"; main() { Num = 0; counter = 3; do /* start do while */ { printf("ntcounter = %2d my school is %s print round %d. ",counter,word,++num); counter = counter + 2 ; } while (counter < 11 ); /* end do while */ getch(); } /* end main() */
  • 49. counter do while printf("ntcounter = %2d my school is %s print round %d. ",counter,word,++num); counter = counter + 2; counter < 11 counter
  • 50.
  • 51.
  • 52. for
  • 53. while {} {}
  • 54. do -while {}1 while
  • 55. 10 28 29 32 33 34 35 6/2