SlideShare ist ein Scribd-Unternehmen logo
   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++

While , For , Do-While Loop
While , For , Do-While LoopWhile , For , Do-While Loop
While , For , Do-While LoopAbhishek Choksi
 
Flow of control C ++ By TANUJ
Flow of control C ++ By TANUJFlow of control C ++ By TANUJ
Flow of control C ++ By TANUJTANUJ ⠀
 
Flow of control by deepak lakhlan
Flow of control by deepak lakhlanFlow of control by deepak lakhlan
Flow of control by deepak lakhlanDeepak Lakhlan
 
Do While Repetition Structure
Do While Repetition StructureDo While Repetition Structure
Do While Repetition StructureShahzu2
 
Control statements
Control statementsControl statements
Control statementsCutyChhaya
 
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.pdfKavitaShinde26
 
presentation on powerpoint template.pptx
presentation on powerpoint template.pptxpresentation on powerpoint template.pptx
presentation on powerpoint template.pptxfarantouqeer8
 
Control Structures Python like conditions and loops
Control Structures Python like conditions and loopsControl Structures Python like conditions and loops
Control Structures Python like conditions and loopsramireddyobulakondar
 
Cprogrammingprogramcontrols
CprogrammingprogramcontrolsCprogrammingprogramcontrols
Cprogrammingprogramcontrolsteach4uin
 
Chapter 4(1)
Chapter 4(1)Chapter 4(1)
Chapter 4(1)TejaswiB4
 
Java Repetiotion Statements
Java Repetiotion StatementsJava Repetiotion Statements
Java Repetiotion StatementsHuda Alameen
 

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

While , For , Do-While Loop
While , For , Do-While LoopWhile , For , Do-While Loop
While , For , Do-While Loop
 
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
 
presentation on powerpoint template.pptx
presentation on powerpoint template.pptxpresentation on powerpoint template.pptx
presentation on powerpoint template.pptx
 
Computer programming 2 - Lesson 7
Computer programming 2 - Lesson 7Computer programming 2 - Lesson 7
Computer programming 2 - Lesson 7
 
Computer programming 2 Lesson 9
Computer programming 2  Lesson 9Computer programming 2  Lesson 9
Computer programming 2 Lesson 9
 
Control Structures Python like conditions and loops
Control Structures Python like conditions and loopsControl Structures Python like conditions and loops
Control Structures Python like conditions and loops
 
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
 

Kürzlich hochgeladen

UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...Sayali Powar
 
size separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceuticssize separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceuticspragatimahajan3
 
Application of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesApplication of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesRased Khan
 
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
 
Neurulation and the formation of the neural tube
Neurulation and the formation of the neural tubeNeurulation and the formation of the neural tube
Neurulation and the formation of the neural tubeSaadHumayun7
 
Morse OER Some Benefits and Challenges.pptx
Morse OER Some Benefits and Challenges.pptxMorse OER Some Benefits and Challenges.pptx
Morse OER Some Benefits and Challenges.pptxjmorse8
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaasiemaillard
 
....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdf....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdfVikramadityaRaj
 
Post Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdf
Post Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdfPost Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdf
Post Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdfPragya - UEM Kolkata Quiz Club
 
slides CapTechTalks Webinar May 2024 Alexander Perry.pptx
slides CapTechTalks Webinar May 2024 Alexander Perry.pptxslides CapTechTalks Webinar May 2024 Alexander Perry.pptx
slides CapTechTalks Webinar May 2024 Alexander Perry.pptxCapitolTechU
 
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...Nguyen Thanh Tu Collection
 
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
 
Salient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxSalient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxakshayaramakrishnan21
 
Advances in production technology of Grapes.pdf
Advances in production technology of Grapes.pdfAdvances in production technology of Grapes.pdf
Advances in production technology of Grapes.pdfDr. M. Kumaresan Hort.
 
The impact of social media on mental health and well-being has been a topic o...
The impact of social media on mental health and well-being has been a topic o...The impact of social media on mental health and well-being has been a topic o...
The impact of social media on mental health and well-being has been a topic o...sanghavirahi2
 
Benefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational ResourcesBenefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational Resourcesdimpy50
 

Kürzlich hochgeladen (20)

UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
 
size separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceuticssize separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceutics
 
Application of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesApplication of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matrices
 
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
 
Neurulation and the formation of the neural tube
Neurulation and the formation of the neural tubeNeurulation and the formation of the neural tube
Neurulation and the formation of the neural tube
 
Morse OER Some Benefits and Challenges.pptx
Morse OER Some Benefits and Challenges.pptxMorse OER Some Benefits and Challenges.pptx
Morse OER Some Benefits and Challenges.pptx
 
Post Exam Fun(da) Intra UEM General Quiz - Finals.pdf
Post Exam Fun(da) Intra UEM General Quiz - Finals.pdfPost Exam Fun(da) Intra UEM General Quiz - Finals.pdf
Post Exam Fun(da) Intra UEM General Quiz - Finals.pdf
 
B.ed spl. HI pdusu exam paper-2023-24.pdf
B.ed spl. HI pdusu exam paper-2023-24.pdfB.ed spl. HI pdusu exam paper-2023-24.pdf
B.ed spl. HI pdusu exam paper-2023-24.pdf
 
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
Operations Management - Book1.p  - Dr. Abdulfatah A. SalemOperations Management - Book1.p  - Dr. Abdulfatah A. Salem
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdf....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdf
 
NCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdfNCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdf
 
Post Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdf
Post Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdfPost Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdf
Post Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdf
 
slides CapTechTalks Webinar May 2024 Alexander Perry.pptx
slides CapTechTalks Webinar May 2024 Alexander Perry.pptxslides CapTechTalks Webinar May 2024 Alexander Perry.pptx
slides CapTechTalks Webinar May 2024 Alexander Perry.pptx
 
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
 
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/
 
Salient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxSalient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptx
 
Advances in production technology of Grapes.pdf
Advances in production technology of Grapes.pdfAdvances in production technology of Grapes.pdf
Advances in production technology of Grapes.pdf
 
The impact of social media on mental health and well-being has been a topic o...
The impact of social media on mental health and well-being has been a topic o...The impact of social media on mental health and well-being has been a topic o...
The impact of social media on mental health and well-being has been a topic o...
 
Benefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational ResourcesBenefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational Resources
 

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.