SlideShare una empresa de Scribd logo
1 de 11
Descargar para leer sin conexión
Lecture05(Control Structure PART-II)
June 27, 2010

       Today's Outline
           Looping statements in C
            • for loop
            • while loop
            • do-while loop
           Jump Statements in C
            • continue
            • break
            • goto


  Md. Mahbub Alam        Structured Programming Language (CSE-   1
                                          1121)
for loop
General Format:
     for( initialization; condition; increment/decrement )
     {
               statements; //body of the loop
      }


                                           Init




                                                         false
                                        Condition


                                                  true


                                       Body of loop



                                         Inc / Dec




Md. Mahbub Alam       Structured Programming Language (CSE-      2
                                       1121)
for loop (Cont.)
Example:

            int sum = 0, count;
            for(count = 1; count <= 5; count++)
                sum = sum + count; //body of the loop
            printf("%d", sum);




Md. Mahbub Alam         Structured Programming Language (CSE-   3
                                         1121)
while loop
General Format:
       while( condition )
       {                                                       Condition
                                                                             false



           statements; //body of the loop
                                                                     true
        }
                                                              Body of loop



      int sum = 0, count;
      count = 1;
      while( count <= 5)
      {
          sum = sum + count;
          count++;
      }
      printf("%d", sum);

 Md. Mahbub Alam      Structured Programming Language (CSE-                  4
                                       1121)
do while loop
Format:
    do
    {
                                                              Body of loop
       statements; //body of the loop
    }while( condition );
                                                                             true
                                                               Condition

   int sum = 0, count;
                                                                     false
   count = 1;
   do
   {
       sum = sum + count;
       count ++;
   }while( count <= 5);
   printf("%d", sum);

 Md. Mahbub Alam      Structured Programming Language (CSE-                         5
                                       1121)
loop (cont.)
• Loop
   – Group of instructions computer executes repeatedly while some
     condition remains true
• Counter-controlled repetition
   – Definite repetition:
   – Known in advance how many times loop will execute
   – Control variable used to count repetitions
• Sentinel-controlled repetition
   – Indefinite repetition
   – Used when number of repetitions not known in advance
   – Sentinel value indicates "end of data"



 Md. Mahbub Alam      Structured Programming Language (CSE-          6
                                       1121)
continue
Skips the remaining statements in the body of a while, for or do…while
statement and proceeds with the next iteration of the loop
 – while and do…while
     • Loop-continuation test is evaluated immediately after the continue
       statement is executed
 – for
     • Increment/ decrement expression is executed first, then the loop-
       continuation test is evaluated
                    int i, sum = 0;
                    for(i=0; ;i++)
                    {
                        if(i%2==1)
                             continue;
                        sum += i;
                    }
  Md. Mahbub Alam        Structured Programming Language (CSE-      7
                                          1121)
break
• Causes immediate exit from a while, for, do…while or switch
  statement.
• Program execution continues with the first statement after the control
  structure.
• Common uses of the break statement
        - Escape early from a loop
        - Skip the remainder of a switch statement

            int i, sum=0;
            for(i=1; ; i++)
            {
               sum += i;
               if(sum >= 10)
                   break;
            }
    Md. Mahbub Alam           Structured Programming Language (CSE-   8
                                               1121)
goto Statement
Format:
        goto label;
                                   main()
         .........
                                   {
         .........
                                      double x,y;
        label:
                                      read:
          statements;
                                      scanf("%lf",&x);
                                      if(x<0)
        label:                          goto read;
         statements;                  y=sqrt(x);
          .........                   printf("%lf",y);
          .........                }
        goto label;


 Md. Mahbub Alam        Structured Programming Language (CSE-   9
                                         1121)
Any Question?




Md. Mahbub Alam   Structured Programming Language (CSE-   10
                                   1121)
Thank You All




Md. Mahbub Alam    Structured Programming Language (CSE-   11
                                    1121)

Más contenido relacionado

La actualidad más candente

La actualidad más candente (19)

5 c control statements looping
5  c control statements looping5  c control statements looping
5 c control statements looping
 
C lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshareC lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshare
 
Presentation on nesting of loops
Presentation on nesting of loopsPresentation on nesting of loops
Presentation on nesting of loops
 
Loops in c
Loops in cLoops in c
Loops in c
 
Loops in c
Loops in cLoops in c
Loops in c
 
Loops in C Programming Language
Loops in C Programming LanguageLoops in C Programming Language
Loops in C Programming Language
 
C Language - Switch and For Loop
C Language - Switch and For LoopC Language - Switch and For Loop
C Language - Switch and For Loop
 
Looping Statement And Flow Chart
 Looping Statement And Flow Chart Looping Statement And Flow Chart
Looping Statement And Flow Chart
 
Statements and Conditions in PHP
Statements and Conditions in PHPStatements and Conditions in PHP
Statements and Conditions in PHP
 
Loops in c programming
Loops in c programmingLoops in c programming
Loops in c programming
 
Loops in c language
Loops in c languageLoops in c language
Loops in c language
 
Looping
LoopingLooping
Looping
 
Chapter 03 conditional statements
Chapter 03   conditional statementsChapter 03   conditional statements
Chapter 03 conditional statements
 
Control statements
Control statementsControl statements
Control statements
 
Iteration
IterationIteration
Iteration
 
Nested loop in C language
Nested loop in C languageNested loop in C language
Nested loop in C language
 
Functuon
FunctuonFunctuon
Functuon
 
Different loops in C
Different loops in CDifferent loops in C
Different loops in C
 
Web Application Development using PHP Chapter 2
Web Application Development using PHP Chapter 2Web Application Development using PHP Chapter 2
Web Application Development using PHP Chapter 2
 

Destacado

09-Runway Configuration ( Highway and Airport Engineering Dr. Sherif El-Badawy )
09-Runway Configuration ( Highway and Airport Engineering Dr. Sherif El-Badawy )09-Runway Configuration ( Highway and Airport Engineering Dr. Sherif El-Badawy )
09-Runway Configuration ( Highway and Airport Engineering Dr. Sherif El-Badawy )Hossam Shafiq I
 
Traffic Concepts (Transportation Engineering)
Traffic Concepts (Transportation Engineering)Traffic Concepts (Transportation Engineering)
Traffic Concepts (Transportation Engineering)Hossam Shafiq I
 
Lecture 5: Railway Engineering ( هندسة السكك الحديدية ) Dr. Alaa Gabr
Lecture 5:  Railway Engineering ( هندسة السكك الحديدية ) Dr. Alaa GabrLecture 5:  Railway Engineering ( هندسة السكك الحديدية ) Dr. Alaa Gabr
Lecture 5: Railway Engineering ( هندسة السكك الحديدية ) Dr. Alaa GabrHossam Shafiq I
 
Route Choice (Transportation Engineering)
Route Choice (Transportation Engineering)Route Choice (Transportation Engineering)
Route Choice (Transportation Engineering)Hossam Shafiq I
 
Signalized Intersections (Transportation Engineering)
Signalized Intersections (Transportation Engineering)Signalized Intersections (Transportation Engineering)
Signalized Intersections (Transportation Engineering)Hossam Shafiq I
 
Speed report from panthpoath to russel square by pronob ghosh buet 1204011
Speed report from panthpoath to russel square by pronob ghosh buet 1204011Speed report from panthpoath to russel square by pronob ghosh buet 1204011
Speed report from panthpoath to russel square by pronob ghosh buet 1204011Pronob Ghosh
 
Vehicle Dynamics (Transportation Engineering)
Vehicle Dynamics (Transportation Engineering)Vehicle Dynamics (Transportation Engineering)
Vehicle Dynamics (Transportation Engineering)Hossam Shafiq I
 
Traffic Detection Systems (Transportation Engineering)
Traffic Detection Systems (Transportation Engineering)Traffic Detection Systems (Transportation Engineering)
Traffic Detection Systems (Transportation Engineering)Hossam Shafiq I
 
Lec 15 Transit Operations (Transportation Engineering Dr.Lina Shbeeb)
Lec 15 Transit Operations (Transportation Engineering Dr.Lina Shbeeb)Lec 15 Transit Operations (Transportation Engineering Dr.Lina Shbeeb)
Lec 15 Transit Operations (Transportation Engineering Dr.Lina Shbeeb)Hossam Shafiq I
 
03-Properties of Asphalt Traditional ( Highway and Airport Engineering Dr. Sh...
03-Properties of Asphalt Traditional ( Highway and Airport Engineering Dr. Sh...03-Properties of Asphalt Traditional ( Highway and Airport Engineering Dr. Sh...
03-Properties of Asphalt Traditional ( Highway and Airport Engineering Dr. Sh...Hossam Shafiq I
 
Lecture 04 Capacity for TWSC (Traffic Engineering هندسة المرور & Dr. Usama Sh...
Lecture 04 Capacity for TWSC (Traffic Engineering هندسة المرور & Dr. Usama Sh...Lecture 04 Capacity for TWSC (Traffic Engineering هندسة المرور & Dr. Usama Sh...
Lecture 04 Capacity for TWSC (Traffic Engineering هندسة المرور & Dr. Usama Sh...Hossam Shafiq I
 
Intelligent Transportation Systems (Transportation Engineering)
Intelligent Transportation Systems (Transportation Engineering)Intelligent Transportation Systems (Transportation Engineering)
Intelligent Transportation Systems (Transportation Engineering)Hossam Shafiq I
 
Freeway & Highway LOS (Transportation Engineering)
Freeway & Highway LOS (Transportation Engineering)Freeway & Highway LOS (Transportation Engineering)
Freeway & Highway LOS (Transportation Engineering)Hossam Shafiq I
 
Geometric Design (Transportation Engineering)
Geometric Design (Transportation Engineering)Geometric Design (Transportation Engineering)
Geometric Design (Transportation Engineering)Hossam Shafiq I
 
Soil Mechanics ميكانيكا التربة & Eng. Ahmed S. Al-Agha
Soil Mechanics ميكانيكا التربة & Eng. Ahmed S. Al-AghaSoil Mechanics ميكانيكا التربة & Eng. Ahmed S. Al-Agha
Soil Mechanics ميكانيكا التربة & Eng. Ahmed S. Al-AghaHossam Shafiq I
 
Parking design in front of CE building BUET by Pronob ghosh 1204011
Parking design in front of CE building BUET by Pronob ghosh 1204011Parking design in front of CE building BUET by Pronob ghosh 1204011
Parking design in front of CE building BUET by Pronob ghosh 1204011Pronob Ghosh
 
10-Intersection Control ( Transportation and Traffic Engineering Dr. Sheriff ...
10-Intersection Control ( Transportation and Traffic Engineering Dr. Sheriff ...10-Intersection Control ( Transportation and Traffic Engineering Dr. Sheriff ...
10-Intersection Control ( Transportation and Traffic Engineering Dr. Sheriff ...Hossam Shafiq I
 

Destacado (20)

09-Runway Configuration ( Highway and Airport Engineering Dr. Sherif El-Badawy )
09-Runway Configuration ( Highway and Airport Engineering Dr. Sherif El-Badawy )09-Runway Configuration ( Highway and Airport Engineering Dr. Sherif El-Badawy )
09-Runway Configuration ( Highway and Airport Engineering Dr. Sherif El-Badawy )
 
Traffic Concepts (Transportation Engineering)
Traffic Concepts (Transportation Engineering)Traffic Concepts (Transportation Engineering)
Traffic Concepts (Transportation Engineering)
 
Trip attraction rate
Trip attraction rateTrip attraction rate
Trip attraction rate
 
Lecture 5: Railway Engineering ( هندسة السكك الحديدية ) Dr. Alaa Gabr
Lecture 5:  Railway Engineering ( هندسة السكك الحديدية ) Dr. Alaa GabrLecture 5:  Railway Engineering ( هندسة السكك الحديدية ) Dr. Alaa Gabr
Lecture 5: Railway Engineering ( هندسة السكك الحديدية ) Dr. Alaa Gabr
 
Route Choice (Transportation Engineering)
Route Choice (Transportation Engineering)Route Choice (Transportation Engineering)
Route Choice (Transportation Engineering)
 
Signalized Intersections (Transportation Engineering)
Signalized Intersections (Transportation Engineering)Signalized Intersections (Transportation Engineering)
Signalized Intersections (Transportation Engineering)
 
Speed report from panthpoath to russel square by pronob ghosh buet 1204011
Speed report from panthpoath to russel square by pronob ghosh buet 1204011Speed report from panthpoath to russel square by pronob ghosh buet 1204011
Speed report from panthpoath to russel square by pronob ghosh buet 1204011
 
Vehicle Dynamics (Transportation Engineering)
Vehicle Dynamics (Transportation Engineering)Vehicle Dynamics (Transportation Engineering)
Vehicle Dynamics (Transportation Engineering)
 
Lecture02(constants, variable & data types)
Lecture02(constants, variable & data types)Lecture02(constants, variable & data types)
Lecture02(constants, variable & data types)
 
Traffic Detection Systems (Transportation Engineering)
Traffic Detection Systems (Transportation Engineering)Traffic Detection Systems (Transportation Engineering)
Traffic Detection Systems (Transportation Engineering)
 
Lecture03(c expressions & operators)
Lecture03(c expressions & operators)Lecture03(c expressions & operators)
Lecture03(c expressions & operators)
 
Lec 15 Transit Operations (Transportation Engineering Dr.Lina Shbeeb)
Lec 15 Transit Operations (Transportation Engineering Dr.Lina Shbeeb)Lec 15 Transit Operations (Transportation Engineering Dr.Lina Shbeeb)
Lec 15 Transit Operations (Transportation Engineering Dr.Lina Shbeeb)
 
03-Properties of Asphalt Traditional ( Highway and Airport Engineering Dr. Sh...
03-Properties of Asphalt Traditional ( Highway and Airport Engineering Dr. Sh...03-Properties of Asphalt Traditional ( Highway and Airport Engineering Dr. Sh...
03-Properties of Asphalt Traditional ( Highway and Airport Engineering Dr. Sh...
 
Lecture 04 Capacity for TWSC (Traffic Engineering هندسة المرور & Dr. Usama Sh...
Lecture 04 Capacity for TWSC (Traffic Engineering هندسة المرور & Dr. Usama Sh...Lecture 04 Capacity for TWSC (Traffic Engineering هندسة المرور & Dr. Usama Sh...
Lecture 04 Capacity for TWSC (Traffic Engineering هندسة المرور & Dr. Usama Sh...
 
Intelligent Transportation Systems (Transportation Engineering)
Intelligent Transportation Systems (Transportation Engineering)Intelligent Transportation Systems (Transportation Engineering)
Intelligent Transportation Systems (Transportation Engineering)
 
Freeway & Highway LOS (Transportation Engineering)
Freeway & Highway LOS (Transportation Engineering)Freeway & Highway LOS (Transportation Engineering)
Freeway & Highway LOS (Transportation Engineering)
 
Geometric Design (Transportation Engineering)
Geometric Design (Transportation Engineering)Geometric Design (Transportation Engineering)
Geometric Design (Transportation Engineering)
 
Soil Mechanics ميكانيكا التربة & Eng. Ahmed S. Al-Agha
Soil Mechanics ميكانيكا التربة & Eng. Ahmed S. Al-AghaSoil Mechanics ميكانيكا التربة & Eng. Ahmed S. Al-Agha
Soil Mechanics ميكانيكا التربة & Eng. Ahmed S. Al-Agha
 
Parking design in front of CE building BUET by Pronob ghosh 1204011
Parking design in front of CE building BUET by Pronob ghosh 1204011Parking design in front of CE building BUET by Pronob ghosh 1204011
Parking design in front of CE building BUET by Pronob ghosh 1204011
 
10-Intersection Control ( Transportation and Traffic Engineering Dr. Sheriff ...
10-Intersection Control ( Transportation and Traffic Engineering Dr. Sheriff ...10-Intersection Control ( Transportation and Traffic Engineering Dr. Sheriff ...
10-Intersection Control ( Transportation and Traffic Engineering Dr. Sheriff ...
 

Similar a Lecture05(control structure part ii)

Similar a Lecture05(control structure part ii) (20)

Loops in c
Loops in cLoops in c
Loops in c
 
Loops in c language
Loops in c languageLoops in c language
Loops in c language
 
Lecture04(control structure part i)
Lecture04(control structure part i)Lecture04(control structure part i)
Lecture04(control structure part i)
 
loops and iteration.docx
loops and iteration.docxloops and iteration.docx
loops and iteration.docx
 
L8
L8L8
L8
 
Lo43
Lo43Lo43
Lo43
 
09
0909
09
 
Session 3
Session 3Session 3
Session 3
 
bai giang java co ban - java cơ bản - bai 2
bai giang java co ban - java cơ bản - bai 2bai giang java co ban - java cơ bản - bai 2
bai giang java co ban - java cơ bản - bai 2
 
06 Loops
06 Loops06 Loops
06 Loops
 
Looping
LoopingLooping
Looping
 
Repetition Control and IO ErrorsPlease note that the mate.docx
Repetition Control and IO ErrorsPlease note that the mate.docxRepetition Control and IO ErrorsPlease note that the mate.docx
Repetition Control and IO ErrorsPlease note that the mate.docx
 
Loops c++
Loops c++Loops c++
Loops c++
 
Loops IN COMPUTER SCIENCE STANDARD 11 BY KR
Loops IN COMPUTER SCIENCE STANDARD 11 BY KRLoops IN COMPUTER SCIENCE STANDARD 11 BY KR
Loops IN COMPUTER SCIENCE STANDARD 11 BY KR
 
Lab 6
Lab 6Lab 6
Lab 6
 
12 lec 12 loop
12 lec 12 loop 12 lec 12 loop
12 lec 12 loop
 
Core java
Core javaCore java
Core java
 
Loops in c++
Loops in c++Loops in c++
Loops in c++
 
Control structuresin c
Control structuresin cControl structuresin c
Control structuresin c
 
2nd year computer science chapter 12 notes
2nd year computer science chapter 12 notes2nd year computer science chapter 12 notes
2nd year computer science chapter 12 notes
 

Último

Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.MateoGardella
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...KokoStevan
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 

Último (20)

Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 

Lecture05(control structure part ii)

  • 1. Lecture05(Control Structure PART-II) June 27, 2010 Today's Outline Looping statements in C • for loop • while loop • do-while loop Jump Statements in C • continue • break • goto Md. Mahbub Alam Structured Programming Language (CSE- 1 1121)
  • 2. for loop General Format: for( initialization; condition; increment/decrement ) { statements; //body of the loop } Init false Condition true Body of loop Inc / Dec Md. Mahbub Alam Structured Programming Language (CSE- 2 1121)
  • 3. for loop (Cont.) Example: int sum = 0, count; for(count = 1; count <= 5; count++) sum = sum + count; //body of the loop printf("%d", sum); Md. Mahbub Alam Structured Programming Language (CSE- 3 1121)
  • 4. while loop General Format: while( condition ) { Condition false statements; //body of the loop true } Body of loop int sum = 0, count; count = 1; while( count <= 5) { sum = sum + count; count++; } printf("%d", sum); Md. Mahbub Alam Structured Programming Language (CSE- 4 1121)
  • 5. do while loop Format: do { Body of loop statements; //body of the loop }while( condition ); true Condition int sum = 0, count; false count = 1; do { sum = sum + count; count ++; }while( count <= 5); printf("%d", sum); Md. Mahbub Alam Structured Programming Language (CSE- 5 1121)
  • 6. loop (cont.) • Loop – Group of instructions computer executes repeatedly while some condition remains true • Counter-controlled repetition – Definite repetition: – Known in advance how many times loop will execute – Control variable used to count repetitions • Sentinel-controlled repetition – Indefinite repetition – Used when number of repetitions not known in advance – Sentinel value indicates "end of data" Md. Mahbub Alam Structured Programming Language (CSE- 6 1121)
  • 7. continue Skips the remaining statements in the body of a while, for or do…while statement and proceeds with the next iteration of the loop – while and do…while • Loop-continuation test is evaluated immediately after the continue statement is executed – for • Increment/ decrement expression is executed first, then the loop- continuation test is evaluated int i, sum = 0; for(i=0; ;i++) { if(i%2==1) continue; sum += i; } Md. Mahbub Alam Structured Programming Language (CSE- 7 1121)
  • 8. break • Causes immediate exit from a while, for, do…while or switch statement. • Program execution continues with the first statement after the control structure. • Common uses of the break statement - Escape early from a loop - Skip the remainder of a switch statement int i, sum=0; for(i=1; ; i++) { sum += i; if(sum >= 10) break; } Md. Mahbub Alam Structured Programming Language (CSE- 8 1121)
  • 9. goto Statement Format: goto label; main() ......... { ......... double x,y; label: read: statements; scanf("%lf",&x); if(x<0) label: goto read; statements; y=sqrt(x); ......... printf("%lf",y); ......... } goto label; Md. Mahbub Alam Structured Programming Language (CSE- 9 1121)
  • 10. Any Question? Md. Mahbub Alam Structured Programming Language (CSE- 10 1121)
  • 11. Thank You All Md. Mahbub Alam Structured Programming Language (CSE- 11 1121)