SlideShare une entreprise Scribd logo
1  sur  11
Télécharger pour lire hors ligne
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)

Contenu connexe

Tendances (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
 

En vedette

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
 

En vedette (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 ...
 

Similaire à Lecture05(control structure part ii)

Similaire à 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
 

Dernier

會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽中 央社
 
How to Manage Closest Location in Odoo 17 Inventory
How to Manage Closest Location in Odoo 17 InventoryHow to Manage Closest Location in Odoo 17 Inventory
How to Manage Closest Location in Odoo 17 InventoryCeline George
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxLimon Prince
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code ExamplesPeter Brusilovsky
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptxVishal Singh
 
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45MysoreMuleSoftMeetup
 
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...Denish Jangid
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文中 央社
 
demyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptxdemyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptxMohamed Rizk Khodair
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismDabee Kamal
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptxPoojaSen20
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...Nguyen Thanh Tu Collection
 
philosophy and it's principles based on the life
philosophy and it's principles based on the lifephilosophy and it's principles based on the life
philosophy and it's principles based on the lifeNitinDeodare
 
Championnat de France de Tennis de table/
Championnat de France de Tennis de table/Championnat de France de Tennis de table/
Championnat de France de Tennis de table/siemaillard
 
The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxheathfieldcps1
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital ManagementMBA Assignment Experts
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...Nguyen Thanh Tu Collection
 

Dernier (20)

會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"
 
Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"
Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"
Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"
 
How to Manage Closest Location in Odoo 17 Inventory
How to Manage Closest Location in Odoo 17 InventoryHow to Manage Closest Location in Odoo 17 Inventory
How to Manage Closest Location in Odoo 17 Inventory
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptx
 
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
 
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
demyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptxdemyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptx
 
Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in Hinduism
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptx
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 
philosophy and it's principles based on the life
philosophy and it's principles based on the lifephilosophy and it's principles based on the life
philosophy and it's principles based on the life
 
Championnat de France de Tennis de table/
Championnat de France de Tennis de table/Championnat de France de Tennis de table/
Championnat de France de Tennis de table/
 
The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptx
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 

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)