Loop in C++
Loops are used to repeatedly execute a block of code multiple times.
Types of Loops
1. For Loop
For loop helps us to execute a block of code a fixed number of times.
Syntax
for (initialization expr; test expr; update expr)
{
// body of the loop
// statements we want to execute
}
2. While Loop
While loop repeatedly executes a block of code till the given condition is true.
Syntax
while (condition)
{
// statements
update_condition;
}
3. Do-While Loop
Do-while loop also executes the block of code till the condition is true but the difference between a while and a do-while loop is that the do-while executes the code once without checking the condition and the test condition is tested at the end of the loop body.
Syntax
do {
// Code to be repeated
} while (condition);
C++ Cheatsheet
This is a C++ programming cheat sheet. It is useful for beginners and intermediates looking to learn or revise the concepts of C++ programming. While learning a new language, it feels annoying to switch pages and find different websites for different concepts that are easily understandable. You can learn C++ concepts very easily using this cheat sheet.
C++ is a high-level programming language. It was developed in 1983 by Bjarne Stroustrup at Bell Labs. It is used for developing various applications.
Contact Us