SlideShare ist ein Scribd-Unternehmen logo
1 von 40
   Statements & block
   If Else
   Else If
   Switch
   While Loop
   For loop
   Do while loop
   Break & continue
   Goto & labels
 Expression+; = staement;
 More than one staement is called
  compund staments.

                     Single stament




                    Compund staments
   When a group of statements or
    compund staments protected by open
    and close braces is called block.
             Open brace



                            Block of codes



              Close brace
   Braces surrounded the staments of
    function definition.
                Open brace




                              Function definition




                Close brace
   Braces surround multiple statements
    of loop constructs too.
                 Open brace




                               Loop multiple
                               statements



                 Close brace
   Write a program to take two float
    numbers and do these tasks upon
    them
    ◦   Multiplication
    ◦   Division
    ◦   Subtraction
    ◦   Addition
    ◦   & find remainder
 If – else is used to control the flow with
  the condition.
 In If-Else, if the IF test is true then if
  statements will executes.
 if IF test is false then Else staements will
  execute.
 Be – careful to put open & close braces if
  you have more than one staement in IF
  or ELSE part.
 Here is an example of if-else
 IF test is not true so the else part will
  execute.
   Here we can check as much test as we
    want.
   Each else work will like separate IF.
   All have one else.
   If all test fails then only else part will
    excute.
   As i told we can do any number of tests.
   But it takes hell amount of time. To avoid
    this we will use switch – case.
If (tes-expression)
           True –statement;
Else If (tes-expression)
           True –statement;
Else If (tes-expression)
           True –statement;
Else If (tes-expression)
           True –statement;
Else If (tes-expression)
           True –statement;
Else
           False statement;
Switch (expression){
Case constant-expression:
statement;
Break;
Case constant-expression:
statement;
Break;
Case constant-expression:
statement;
Break;
Case constant-expression:
statement;
Break;
Default: statement;
}
 In switch-case ,we are switching on a
  expression . The expression must be
  integer value. We can do switch
  caseupon string, float or anything else.
 There are more than one case.
 Here we are comparing the case value
  with switch.
 We have a default value if none of case
  satisfies.
   Executing a block of code for a certain no of
    periods.
   We need a condition to test.
   We have to increment or decrement.
   If we have more than one statement then we
    need to put those within curly brace’{}’
   We have three types of loops
    ◦ For loop
    ◦ While loop
    ◦ Do – while loop
   For a loop we need
   Initialized from where you want to start
    ◦ I = 0 or [or any number from where you want]
   Test expression or you can say test
    condition
    ◦ I <= or< or >= or > [certain value]
   Adjustments(increment or decrement)
    ◦ i++
    ◦ i--
 When we don’t use any initializer, test-
  expression & adjustment. The loop
  becomes infinite loop.
 Can we use infinite loop? Yes but with a
  break and a condition.
 The loop will continue infinite until unless
  our condition satisfies. Once condition
  satisfies we will come out using break;
  statement.
 In while loop we have only test-
  expression is tested.
 If expression testing results true then
  the statement or statements executes.
 In do while loop first the statements
  executes
 Next is testing expression
 Here the must run once even the
  expression test id false.
 But in for & while to execute statement
  the expression must be true
 Write all the three programs which I
  showed you on previous slide
  initializing the I value to ‘7’.
 Answer us what you will get and
  when?
 Write a program to display 1 to 100
  using
 For loop
 While loop
 Do-while loop
1.    Write a program to display all odd numbers in
      between 1 to 50.advise
     1.   Use for/while loop
2.    Write a program to display all even numbers in
      between 1 to 50.advise
     1.   Use for/while loop
3.    Write a program to display all numbers in between 1
      to 50 which are less than 26.advise
     1.   Use for/while loop
4.    Write a program to display all numbers in between 1
      to 50 which are greater than 25.advise
     1.   Use for/while loop
 When break occurs it send the
  execution to out of the loop or switch.
 When continue occurs it sends the
  execution right to the testing
  expression.
 These two can be used inside of
  switches and loops
Timesjobs.com
           Click me to hire




Check the links for more informations.
You can put feedback and comments.

Weitere ähnliche Inhalte

Ähnlich wie nuts and bolts of c++

Ähnlich wie nuts and bolts of c++ (20)

cpu.pdf
cpu.pdfcpu.pdf
cpu.pdf
 
Flow of control C ++ By TANUJ
Flow of control C ++ By TANUJFlow of control C ++ By TANUJ
Flow of control C ++ By TANUJ
 
Flow of control by deepak lakhlan
Flow of control by deepak lakhlanFlow of control by deepak lakhlan
Flow of control by deepak lakhlan
 
Decision making and branching
Decision making and branchingDecision making and branching
Decision making and branching
 
M C6java6
M C6java6M C6java6
M C6java6
 
Loops and iteration.docx
Loops and iteration.docxLoops and iteration.docx
Loops and iteration.docx
 
Do While Repetition Structure
Do While Repetition StructureDo While Repetition Structure
Do While Repetition Structure
 
Control statements
Control statementsControl statements
Control statements
 
UNIT 1- RELATIONAL DATABASE DESIGN USING PLSQL.pdf
UNIT 1- RELATIONAL DATABASE DESIGN USING PLSQL.pdfUNIT 1- RELATIONAL DATABASE DESIGN USING PLSQL.pdf
UNIT 1- RELATIONAL DATABASE DESIGN USING PLSQL.pdf
 
Computer programming 2 Lesson 9
Computer programming 2  Lesson 9Computer programming 2  Lesson 9
Computer programming 2 Lesson 9
 
Computer programming 2 - Lesson 7
Computer programming 2 - Lesson 7Computer programming 2 - Lesson 7
Computer programming 2 - Lesson 7
 
07 flow control
07   flow control07   flow control
07 flow control
 
Control structures IN SWIFT
Control structures IN SWIFTControl structures IN SWIFT
Control structures IN SWIFT
 
Cprogrammingprogramcontrols
CprogrammingprogramcontrolsCprogrammingprogramcontrols
Cprogrammingprogramcontrols
 
C language 2
C language 2C language 2
C language 2
 
Chap3java5th
Chap3java5thChap3java5th
Chap3java5th
 
Chapter 4(1)
Chapter 4(1)Chapter 4(1)
Chapter 4(1)
 
Java Repetiotion Statements
Java Repetiotion StatementsJava Repetiotion Statements
Java Repetiotion Statements
 
Loop and while Loop
Loop and while LoopLoop and while Loop
Loop and while Loop
 
dizital pods session 5-loops.pptx
dizital pods session 5-loops.pptxdizital pods session 5-loops.pptx
dizital pods session 5-loops.pptx
 

Kürzlich hochgeladen

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

Kürzlich hochgeladen (20)

This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
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
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
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
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 

nuts and bolts of c++

  • 1.
  • 2. Statements & block  If Else  Else If  Switch  While Loop  For loop  Do while loop  Break & continue  Goto & labels
  • 3.  Expression+; = staement;  More than one staement is called compund staments. Single stament Compund staments
  • 4. When a group of statements or compund staments protected by open and close braces is called block. Open brace Block of codes Close brace
  • 5. Braces surrounded the staments of function definition. Open brace Function definition Close brace
  • 6. Braces surround multiple statements of loop constructs too. Open brace Loop multiple statements Close brace
  • 7.
  • 8.
  • 9.
  • 10.
  • 11. Write a program to take two float numbers and do these tasks upon them ◦ Multiplication ◦ Division ◦ Subtraction ◦ Addition ◦ & find remainder
  • 12.  If – else is used to control the flow with the condition.  In If-Else, if the IF test is true then if statements will executes.  if IF test is false then Else staements will execute.  Be – careful to put open & close braces if you have more than one staement in IF or ELSE part.
  • 13.  Here is an example of if-else  IF test is not true so the else part will execute.
  • 14.
  • 15. Here we can check as much test as we want.  Each else work will like separate IF.  All have one else.  If all test fails then only else part will excute.  As i told we can do any number of tests.  But it takes hell amount of time. To avoid this we will use switch – case.
  • 16. If (tes-expression) True –statement; Else If (tes-expression) True –statement; Else If (tes-expression) True –statement; Else If (tes-expression) True –statement; Else If (tes-expression) True –statement; Else False statement;
  • 17.
  • 18. Switch (expression){ Case constant-expression: statement; Break; Case constant-expression: statement; Break; Case constant-expression: statement; Break; Case constant-expression: statement; Break; Default: statement; }
  • 19.  In switch-case ,we are switching on a expression . The expression must be integer value. We can do switch caseupon string, float or anything else.  There are more than one case.  Here we are comparing the case value with switch.  We have a default value if none of case satisfies.
  • 20.
  • 21.
  • 22. Executing a block of code for a certain no of periods.  We need a condition to test.  We have to increment or decrement.  If we have more than one statement then we need to put those within curly brace’{}’  We have three types of loops ◦ For loop ◦ While loop ◦ Do – while loop
  • 23. For a loop we need  Initialized from where you want to start ◦ I = 0 or [or any number from where you want]  Test expression or you can say test condition ◦ I <= or< or >= or > [certain value]  Adjustments(increment or decrement) ◦ i++ ◦ i--
  • 24.
  • 25.
  • 26.  When we don’t use any initializer, test- expression & adjustment. The loop becomes infinite loop.  Can we use infinite loop? Yes but with a break and a condition.  The loop will continue infinite until unless our condition satisfies. Once condition satisfies we will come out using break; statement.
  • 27.
  • 28.  In while loop we have only test- expression is tested.  If expression testing results true then the statement or statements executes.
  • 29.
  • 30.
  • 31.  In do while loop first the statements executes  Next is testing expression  Here the must run once even the expression test id false.  But in for & while to execute statement the expression must be true
  • 32.
  • 33.
  • 34.
  • 35.  Write all the three programs which I showed you on previous slide initializing the I value to ‘7’.  Answer us what you will get and when?
  • 36.  Write a program to display 1 to 100 using  For loop  While loop  Do-while loop
  • 37. 1. Write a program to display all odd numbers in between 1 to 50.advise 1. Use for/while loop 2. Write a program to display all even numbers in between 1 to 50.advise 1. Use for/while loop 3. Write a program to display all numbers in between 1 to 50 which are less than 26.advise 1. Use for/while loop 4. Write a program to display all numbers in between 1 to 50 which are greater than 25.advise 1. Use for/while loop
  • 38.  When break occurs it send the execution to out of the loop or switch.  When continue occurs it sends the execution right to the testing expression.  These two can be used inside of switches and loops
  • 39.
  • 40. Timesjobs.com Click me to hire Check the links for more informations. You can put feedback and comments.