Search for tag: "loop"

Vector, Part 3) Print each element of vector in C++

+12 More
From  Lane Schwartz 7 plays 0  

Vector, Part 2) Iterate over contents of vector in C++

#include <iostream>#include <vector> using std::cout; using std::vector; int main() { auto my_data = vector<int>{17, 25, -300, 14}; for (auto item : my_data) { …

+19 More
From  Lane Schwartz 8 plays 0  

Basic I/O, Part 7) Read ints from file

+16 More
From  Lane Schwartz 17 plays 0  

Basic I/O, Part 5) Prompt user within loop

+19 More
From  Lane Schwartz 11 plays 0  

Basic I/O, Part 3) Prompt user before cin

+17 More
From  Lane Schwartz 11 plays 0  

Basic I/O, Part 9) Write ints to file

+16 More
From  Lane Schwartz 16 plays 0  

Command line arguments in C++

#include <iostream> int main(int argc, char** argv) { for (int n{0}; n <= argc; n += 1) { std::cout << argv[n] << '\n'; } return 0; }

+19 More
From  Lane Schwartz 2 plays 0  

Basic for loop in C++

#include <iostream> int main() { for (int n{10}; n > 0; n = n - 1) { std::cout << n << "\n"; } }

+19 More
From  Lane Schwartz 1 plays 0