SlideShare una empresa de Scribd logo
1 de 55
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

Más contenido relacionado

Destacado

Destacado (8)

Matematika itu mudah dan menyenangkan
Matematika itu mudah dan menyenangkanMatematika itu mudah dan menyenangkan
Matematika itu mudah dan menyenangkan
 
Andriod tp1 LRR
Andriod tp1 LRRAndriod tp1 LRR
Andriod tp1 LRR
 
Adding slide share instructions
Adding slide share instructionsAdding slide share instructions
Adding slide share instructions
 
Diego ricol freyre
Diego ricol freyreDiego ricol freyre
Diego ricol freyre
 
The sea gull and the tortoise
The sea gull and the tortoiseThe sea gull and the tortoise
The sea gull and the tortoise
 
diego ricol
diego ricol diego ricol
diego ricol
 
Diego ricol freyre
Diego ricol freyreDiego ricol freyre
Diego ricol freyre
 
Fotografía surrealista
Fotografía surrealistaFotografía surrealista
Fotografía surrealista
 

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

รายงานการเขียนคำสั่งควบคุมแบบวนซ้ำ กลุ่ม 4 ม. 6 ห้อง2
รายงานการเขียนคำสั่งควบคุมแบบวนซ้ำ กลุ่ม 4 ม. 6 ห้อง2รายงานการเขียนคำสั่งควบคุมแบบวนซ้ำ กลุ่ม 4 ม. 6 ห้อง2
รายงานการเขียนคำสั่งควบคุมแบบวนซ้ำ กลุ่ม 4 ม. 6 ห้อง2Pookie Pook
 
8 arrays and pointers
8  arrays and pointers8  arrays and pointers
8 arrays and pointersMomenMostafa
 
halstead software science measures
halstead software science measureshalstead software science measures
halstead software science measuresDeepti Pillai
 
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.pdfJeancarlosPatalasanc
 
Infix prefix postfix
Infix prefix postfixInfix prefix postfix
Infix prefix postfixSelf-Employed
 
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 RAMALINGAMSaraswathiRamalingam
 
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 programsab11cs001
 
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 numbersXequeMateShannon
 
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 AlgebraEric Normand
 

Similar a การเขียนคำสั่งควบคุมแบบวนซ้ำ กลุ่ม 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
 

Último

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 

Último (20)

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 

การเขียนคำสั่งควบคุมแบบวนซ้ำ กลุ่ม 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