Posts

Showing posts with the label loops

Flow of Control in C++ || if-else-else if in C++ || Learn about while, do-while, for and for-each (range based for) loops || Return statements || break and continue

Image
  Control flow or Flow of Control in C++ by - Yashvardhan Singh As you it was already discussed in previous blogs, C++ offers many statements to execute only a selected block of code, instead of blindly executing from top to bottom, today we are going to elaborate upon such statements. The Control Flow statements can be divided under the following categories: Decision making statements Looping statements Branching statements (Jump statements and return) Others (async, coroutines, exceptions, etc.,) ...to be discussed later Now let us discuss about the same:- Decision making statements:- If-else : These C++ statements help you to make a decision, any command based upon 'if then' or 'if then else'  logic can be written using if else statements. Example: #include   <iostream> int   main () {      bool   hungry  =  true ;      if  ( hungry )     {       ...