Showing posts with label STANDARD TEMPLATE LIBRARY. Show all posts
Showing posts with label STANDARD TEMPLATE LIBRARY. Show all posts

Tuesday, February 16, 2016

STANDARD TEMPLATE LIBRARY

AIM:
         To implement a C++ program to illustrate the concept of standard template library.

ALGORITHM:

Step 1: Include the header files
Step 2: Create a vector to store int
Step 3: Display the original size to store int
Step 4: Push 5 values into the vector using for loop
Step 5: Display extended size of vec
Step 6: Access 5 values from the vector
Step 7: Use iterator to access the values
PROGRAM:
#include <iostream.h>
#include <vector>
using namespace std;
int main()
{
  vector<int> vec;
  int i;
  cout << "vector size = " << vec.size() << endl;
  for(i = 0; i < 5; i++)
{

     vec.push_back(i);
}
  cout << "extended vector size = " << vec.size() << endl;
     for(i = 0; i < 5; i++)