SlideShare ist ein Scribd-Unternehmen logo
1 von 15
FOR LOOP
           PRESENTED BY:
      FAROOQ MUSTAFA JOYIA
        (169-FET/BSME/F11-B)
  DEPARTEMENT OF MECHANICAL ENGINEERING
  FACULTY OF ENGINEERING AND TECHNOLOGY
INTERNATIONAL ISLAMIC UNIVERSITY ISLAMABAD
AGENDA
 WHAT IS LOOPING?
 GENERAL FORM OF FOR LOOP
 DESCRIPTION OF GENERAL FORM
 EXECUTION
 NESTING THE LOOP
 MULTIPLE ASSIGNMENTS IN FOR
  LOOP
 NULL STATEMENT
WHAT IS LOOPING?

 LOOPING,    also called iteration, is
 used in programming to perform the
   same set of instructions over and
over until certain specified conditions
             are satisfied.
 Here we will discuss about for loop
GENERAL FORM
   General form of for statement is
    for(expression1;expression2;expression3)
   {
   Statement1;
   Statement2;
   .
   .
   .

   }
EXPRESSION 1

 Thisis some kind of
 expression which initializes the
 control variable. This
 statement is only carried out
 once before the starting of for
 loop.
EXPRESSION 2

 Thisexpression is evaluated at
 the beginning of for loop and
 the loop is only carried out
 when this expression is true.
EXPRESSION 3

  This is some kind of
expression for altering the
 value of control variable.
         e.g. i++
EXECUTION OF FOR LOOP
   When the loop is started
    normally a control variable is
    initialized by executing.
   Expression_2 is tested if it is
    false then control is
    transferred outside the loop
    otherwise do next step_3.
   Body of loop is executed.
   Value of control is altered by
    expression 3.
   Step 2 and 4 are repeated
    until condition becomes false.
NESTING THE LOOPS

 When  a for loop is
 completely
 embedded within
 for loop, the
 structure is called
 nested for loop.
Inner   for loop must finish
 first than outer loop must
 start another iteration, if
 the specified condition is
 still met.
MULTIPLE ASSIGNMENTS IN
       FOR LOOP
 We   can use more than one
 initialization statement &more
 than one increment decrement
 statement. However only one
 condition is allowed within a for
 loop.
 main()
{
 int x,y;
 for(x=1,y=10;x<=10;x++,y--)
 printf (“x=%dt y=%dn:,x,y);
NULL STATEMENT
 The for statement does not end with a
  semicolon.
 The for statement has within it either a
  statement block that ends with the closing
  brace or a single statement that ends with
  a semicolon.
THE END

Weitere ähnliche Inhalte

Was ist angesagt?

Looping statement
Looping statementLooping statement
Looping statement
ilakkiya
 
3.looping(iteration statements)
3.looping(iteration statements)3.looping(iteration statements)
3.looping(iteration statements)
Hardik gupta
 

Was ist angesagt? (20)

Function overloading ppt
Function overloading pptFunction overloading ppt
Function overloading ppt
 
SWITCH CASE STATEMENT IN C
SWITCH CASE STATEMENT IN CSWITCH CASE STATEMENT IN C
SWITCH CASE STATEMENT IN C
 
Looping statement
Looping statementLooping statement
Looping statement
 
Types of loops in c language
Types of loops in c languageTypes of loops in c language
Types of loops in c language
 
Operator.ppt
Operator.pptOperator.ppt
Operator.ppt
 
LR Parsing
LR ParsingLR Parsing
LR Parsing
 
Loops c++
Loops c++Loops c++
Loops c++
 
07. Virtual Functions
07. Virtual Functions07. Virtual Functions
07. Virtual Functions
 
Loops in c
Loops in cLoops in c
Loops in c
 
Control statments in c
Control statments in cControl statments in c
Control statments in c
 
Control statements
Control statementsControl statements
Control statements
 
Loops in c++ programming language
Loops in c++ programming language Loops in c++ programming language
Loops in c++ programming language
 
Control structure C++
Control structure C++Control structure C++
Control structure C++
 
If statements in c programming
If statements in c programmingIf statements in c programming
If statements in c programming
 
Loops Basics
Loops BasicsLoops Basics
Loops Basics
 
Control statement in c
Control statement in cControl statement in c
Control statement in c
 
3.looping(iteration statements)
3.looping(iteration statements)3.looping(iteration statements)
3.looping(iteration statements)
 
Chap 6(decision making-looping)
Chap 6(decision making-looping)Chap 6(decision making-looping)
Chap 6(decision making-looping)
 
D Flip Flop
D Flip Flop D Flip Flop
D Flip Flop
 
Addressing modes
Addressing modesAddressing modes
Addressing modes
 

Ähnlich wie PRESENTATION ON FOR LOOP

Chapter 9 - Loops in C++
Chapter 9 - Loops in C++Chapter 9 - Loops in C++
Chapter 9 - Loops in C++
Deepak Singh
 

Ähnlich wie PRESENTATION ON FOR LOOP (20)

C language 2
C language 2C language 2
C language 2
 
Loop
LoopLoop
Loop
 
Cse lecture-7-c loop
Cse lecture-7-c loopCse lecture-7-c loop
Cse lecture-7-c loop
 
Comp ppt (1)
Comp ppt (1)Comp ppt (1)
Comp ppt (1)
 
Control statements
Control statementsControl statements
Control statements
 
Computer programming 2 Lesson 8
Computer programming 2  Lesson 8Computer programming 2  Lesson 8
Computer programming 2 Lesson 8
 
Do While Repetition Structure
Do While Repetition StructureDo While Repetition Structure
Do While Repetition Structure
 
Loops In C++
Loops In C++Loops In C++
Loops In C++
 
Deeksha gopaliya
Deeksha gopaliyaDeeksha gopaliya
Deeksha gopaliya
 
Looping in c++
Looping in c++Looping in c++
Looping in c++
 
Looping in c++
Looping in c++Looping in c++
Looping in 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
 
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
 
What is loops? What is For loop?
What is loops? What is For loop?What is loops? What is For loop?
What is loops? What is For loop?
 
Java Repetiotion Statements
Java Repetiotion StatementsJava Repetiotion Statements
Java Repetiotion Statements
 
Chapter 9 - Loops in C++
Chapter 9 - Loops in C++Chapter 9 - Loops in C++
Chapter 9 - Loops in C++
 
Decision Making Statement in C ppt
Decision Making Statement in C pptDecision Making Statement in C ppt
Decision Making Statement in C ppt
 
Loops in c
Loops in cLoops in c
Loops in c
 
2. Control structures with for while and do while.ppt
2. Control structures with for while and do while.ppt2. Control structures with for while and do while.ppt
2. Control structures with for while and do while.ppt
 
Loop structures
Loop structuresLoop structures
Loop structures
 

Kürzlich hochgeladen

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Kürzlich hochgeladen (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
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...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
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
 
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...
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 

PRESENTATION ON FOR LOOP

  • 1.
  • 2. FOR LOOP PRESENTED BY:  FAROOQ MUSTAFA JOYIA (169-FET/BSME/F11-B) DEPARTEMENT OF MECHANICAL ENGINEERING FACULTY OF ENGINEERING AND TECHNOLOGY INTERNATIONAL ISLAMIC UNIVERSITY ISLAMABAD
  • 3. AGENDA  WHAT IS LOOPING?  GENERAL FORM OF FOR LOOP  DESCRIPTION OF GENERAL FORM  EXECUTION  NESTING THE LOOP  MULTIPLE ASSIGNMENTS IN FOR LOOP  NULL STATEMENT
  • 4. WHAT IS LOOPING?  LOOPING, also called iteration, is used in programming to perform the same set of instructions over and over until certain specified conditions are satisfied.  Here we will discuss about for loop
  • 5. GENERAL FORM  General form of for statement is  for(expression1;expression2;expression3)  {  Statement1;  Statement2;  .  .  .  }
  • 6. EXPRESSION 1  Thisis some kind of expression which initializes the control variable. This statement is only carried out once before the starting of for loop.
  • 7. EXPRESSION 2  Thisexpression is evaluated at the beginning of for loop and the loop is only carried out when this expression is true.
  • 8. EXPRESSION 3  This is some kind of expression for altering the value of control variable.  e.g. i++
  • 9. EXECUTION OF FOR LOOP  When the loop is started normally a control variable is initialized by executing.  Expression_2 is tested if it is false then control is transferred outside the loop otherwise do next step_3.  Body of loop is executed.  Value of control is altered by expression 3.  Step 2 and 4 are repeated until condition becomes false.
  • 10. NESTING THE LOOPS  When a for loop is completely embedded within for loop, the structure is called nested for loop.
  • 11. Inner for loop must finish first than outer loop must start another iteration, if the specified condition is still met.
  • 12. MULTIPLE ASSIGNMENTS IN FOR LOOP  We can use more than one initialization statement &more than one increment decrement statement. However only one condition is allowed within a for loop.
  • 13.  main() {  int x,y;  for(x=1,y=10;x<=10;x++,y--)  printf (“x=%dt y=%dn:,x,y);
  • 14. NULL STATEMENT  The for statement does not end with a semicolon.  The for statement has within it either a statement block that ends with the closing brace or a single statement that ends with a semicolon.