Skip to content

Commit

Permalink
added two programs that utilze vectors.
Browse files Browse the repository at this point in the history
  • Loading branch information
jesushilarioh committed Nov 12, 2016
1 parent 1eac3c4 commit 05713db
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Last Updated: November 11th, 2016
//**************************************************************
#include <iostream>
#include <vector> // Needed to defice vectors
#include <vector> // Needed to define vectors
#include <iomanip>
using namespace std;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//*****************************************************************
// This program demonsrates the range-based for loop with a vector.
//
// By: Jesus Hilario Hernandez
// Last Updated: November 12, 2016;
//*****************************************************************
#include <iostream>
#include <vector>
using namespace std;

int main()
{
// Define and initialize a vector.
vector<int> numbers {10, 20, 30, 40, 50 };

// Display the vector elements.
for (int val : numbers)
{
cout << val << endl;
}

return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Jesuss-iMac:7.12 If You Plan to Continue in Computer Science: Introduction to the STL vector hernandezfamily$ g++ -std=c++11 7-25.cpp
Jesuss-iMac:7.12 If You Plan to Continue in Computer Science: Introduction to the STL vector hernandezfamily$ ./a.out
10
20
30
40
50
Jesuss-iMac:7.12 If You Plan to Continue in Computer Science: Introduction to the STL vector hernandezfamily$

0 comments on commit 05713db

Please sign in to comment.