C++ Loops |
-- Learning is not just about technology, but also about dreams!
- Home
- HTML
- JavaScript
- CSS
- Vue
- React
- Python3
- Java
- C
- C++
- C#
- AI
- Go
- SQL
- Linux
- VS Code
- Bootstrap
- Git
- Local Bookmarks
C++ Tutorial
C++ Tutorial C++ Introduction C++ Environment Setup C++ Basic Syntax C++ Comments C++ Data Types C++ Variable Types C++ Variable Scope C++ Constants C++ Modifier Types C++ Storage Classes C++ Operators C++ Loops C++ Decision Making C++ Functions C++ Numbers C++ Arrays C++ Strings C++ Pointers C++ References C++ Date & Time C++ Basic Input/Output C++ struct C++ vector container C++ Data Structures
C++ Object-Oriented
C++ Classes & Objects C++ Inheritance C++ Overloading C++ Polymorphism C++ Data Abstraction C++ Data Encapsulation C++ Interfaces (Abstract Classes)
C++ Advanced Tutorial
C++ Files and Streams C++ Exception Handling C++ Dynamic Memory C++ Namespaces C++ Templates C++ Preprocessor C++ Signal Handling C++ Multithreading C++ Web Programming
C++ Resource Library
C++ STL Tutorial C++ Import Standard Library C++ Standard Library C++ Useful Resources C++ Examples C++ Quiz <a href="#" title="C++ Standard Input/Output β ">C++ Standard Input/Output β <a href="#" title="C++ File Input/Output Library β ">C++ File Input/Output Library β <a href="#" title="C++ Standard Library ">C++ Standard Library <a href="#" title="C++ Standard Library ">C++ Standard Library <a href="#" title="C++ Container Class ">C++ Container Class <a href="#" title="C++ Container Class ">C++ Container Class <a href="#" title="C++ Container Class ">C++ Container Class <a href="#" title="C++ Container ">C++ Container <a href="#" title="C++ Container Class ">C++ Container Class <a href="#" title="C++ Container Class ">C++ Container Class <a href="#" title="C++ Container Class ">C++ Container Class <a href="#" title="C++ Container Class ">C++ Container Class <a href="#" title="C++ Container Class ">C++ Container Class <a href="#" title="C++ Container Class ">C++ Container Class <a href="#" title="C++ Container Class
C++ Operators C++ Decision Making
Explore Further
Programming Languages
Programming
Scripting Languages
Software
Scripts
Web Service
Network Services
Development Tools
Web Design & Development
Computer Science
C++ Loops
Sometimes, you may need to execute the same block of code multiple times. In general, statements are executed sequentially: The first statement in a function is executed first, followed by the second, and so on.
Programming languages provide various control structures that allow for more complicated execution paths.
Loop statements allow us to execute a statement or group of statements multiple times. The following is the general form of a loop statement in most programming languages:
Loop Types
C++ programming language provides the following types of loops to handle looping requirements. Click the following links to check their details.
| Loop Type | Description |
|---|---|
| while loop | Repeats a statement or group of statements while a given condition is true. It tests the condition before executing the loop body. |
| for loop | Executes a sequence of statements multiple times and abbreviates the code that manages the loop variable. |
| do...while loop | Similar to a while statement, except that it tests the condition at the end of the loop body. |
| Nested loops | You can use one or more loops inside any while, for, or do..while loop. |
Loop Control Statements
Loop control statements change execution from its normal sequence. When execution leaves a scope, all automatic objects that were created in that scope are destroyed.
C++ provides the following control statements. Click the following links to check their details.
| Control Statement | Description |
|---|---|
| break statement | Terminates the loop or switch statement and transfers execution to the statement immediately following the loop or switch. |
| continue statement | Causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating. |
| goto statement | Transfers control to a labeled statement. Note: It is recommended not to use goto statement in your program. |
YouTip