Program to use vectors in c++


  #include<iostream>
#include<vector>
using namespace std;
int main()
{
	vector<int>arr(5);
	for (int i = 0; i < arr.size(); i++)
	{
		arr[i] = 0;
	}
	arr.push_back(5);
	cout << "1st value is:" << arr.front() << endl;
	cout << "Last value of the array is:" << arr.back() << endl;
	cout << "To see the 3rd index:" << arr.at(3) << endl;
	for (int i = 0; i < arr.size(); i++)
	{
		cout << "Values of the array are:" << arr[i] << endl;
	}
	getchar();
	getchar();
	return 0;
}     

          

       
 

Comments

Popular posts from this blog

Multiple inheritance,friend function and multiple file in oop(object oriented programming)

Concepts of OOP (object oriented programming)

Concepts in c++........