

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Loops in C and C++
In this tutorial, we will be discussing a program to understand loops in C and C++.
Looping in programming is used when we have to execute a given block code again and again. It takes in the approach for writing the same code line again and again and promoted DRY code practice.
Example
For loop
#include <iostream> using namespace std; int main(){ for (int i = 1; i <= 10; i++){ cout << "Hello World\n"; } return 0; }
Output
Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World
While loop
#include <iostream> using namespace std; int main(){ int i = 1; while (i < 6){ cout << "Hello World\n"; i++; } return 0; }
Output
Hello World Hello World Hello World Hello World Hello World
- Related Questions & Answers
- For and While loops in Arduino
- Loops in Java
- Array flattening using loops and recursion in JavaScript
- What types of loops are supported in C#?
- For Loops in Javascript
- Loops in Dart Programming
- Loops and Control Statements (continue, break and pass) in Python
- Write a C program to work on statements using functions and loops
- What do you mean by odd loops in C language?
- How to use multiple for and while loops together in Python?
- How to use nested loops in Python?
- Finding closed loops in a number - JavaScript
- What is the difference between for...in and for...of loops in JavaScript?
- Reverse array with for loops JavaScript
- Demonstrate nested loops with return statements in JavaScript?
Advertisements