Search
 
SCRIPT & CODE EXAMPLE
 

CPP

nested loop c++

#include <iostream>
using namespace std;

int main() {
    int weeks = 3, days_in_week = 7;

    for (int i = 1; i <= weeks; ++i) {
        cout << "Week: " << i << endl;

        for (int j = 1; j <= days_in_week; ++j) {
            // break during the 2nd week
            if (i == 2) {
                break;
            }
            cout << "    Day:" << j << endl;
        }
    }
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: Chef and Races codechef solution in c++ 
Cpp :: C++ 4.3.2 (gcc-4.3.2) sample 
Cpp :: C++ Things to Remember 
Cpp :: kruskal algorithm in c++ 
Cpp :: bounded and unbounded solution in lpp 
Cpp :: cicli informatica c++ 
Cpp :: online convert c++ code to assembly language 
Cpp :: assoc-right antlr 
Cpp :: irremoteesp8266 example 
Cpp :: jquery ajax post json asp.net core 
Cpp :: c++ ascii value 
Cpp :: c++ string to vector int 
Cpp :: sort c++ array 
Cpp :: how to write hello world c++ 
Cpp :: declare a variable in cpp 
Cpp :: how to replace an element in array in c++ 
Cpp :: open a url with dev c 
Cpp :: flags of open operation c++ 
C :: boilerplate c 
C :: terminal size in c 
C :: Sorting number excluding elements in highest to lowest 
C :: random number in c 
C :: dvlprroshan 
C :: is it possible to access argv in function 
C :: C percentage program 
C :: find smallest number in array in c 
C :: recursion to convert decimal to binary 
C :: c read csv 
C :: Hello world in C programming language 
C :: how to read keyboard input in C 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =