I wrote the code for Arithmetic, relational and binary operations. Here i have intilaised all inputs. I want to give inputs from keyboard instead of intialisation or direct Push_back from loop. How to do this? Please check the following code and please help me to give inputs from keyboard.

#include<iostream>
#include<vector>
#include<deque>
#include<list>
#include<algorithm>
#include<functional>
#include "print.hpp"
using namespace std;
int main()
{
	vector<int> V1;  //vector container for integer elements
	deque<int> V2;  //dequeu container for integer elements
	list<int> V3;      //list container for integer elements
	list<float>V4;   //list container for float elements		

	deque<int>::iterator pos;		// declaration of iterator	

	//initialisation of binary values
	bool a[8]={1,0,1,0,1,0,1,0};
	bool b[8]={1,1,1,1,1,1,1,1};
	
	//vector container for boolean elements
	vector<bool> va(a, a + 8);   
	vector<bool> vb(b, b + 8);
	vector<bool> vc(8);

		
	
	//append elements from 12 to 18 in Vector container V1
	for(int i=12;i<=18;++i)
	{
		  V1.push_back(i); 	//inserts an element at the back of the collection
	}

		
	//append elements from 2 to 8 in deque container V2
	for(int i=2;i<=8;++i)
	{
		  V2.push_front(i);	//inserts an element at the front of the collection
	}
	
	
	char ch;
	do
	{
	cout<<"\nSelect any one peration\n1.Add (V1+V2)\n2.Subtract (V1-V2)\n3.Multiplication (V1*5)\n4.Division(V2/5)\n5.Equal_to\n6.Greater\n7.Less_equal\n8.Logical operations"<<endl;
	cin>>ch;
	switch(ch)
	{
	case '1': 
                          //transform  resulted element to list V3 after addition of each element in                       //vector V1 and deque V2
			 // - Add transformed values
	transform(V1.begin(), V1.end(),	//First sorce range
				V2.begin(),	//Second source range
				back_inserter(V3),		//destination 
				plus<int>());	//operation	
			
	PRINT_ELEMENTS(V1,"V1:    ");		//display the elements of V1
	PRINT_ELEMENTS(V2,"V2:    ");		//display the elements of V2
	PRINT_ELEMENTS(V3,"V1+V2: ");	//dispaly the resulted output
	V3.clear();
	cout<<endl<<endl;
	break;
	case '2': 
	//transform  resulted element to list V3 after subtraction of each element           	// - Subtract transformed values
	transform(V1.begin(), V1.end(),		//First sorce range
			V2.begin(),	//Second source range
			back_inserter(V3),	//destination 
			minus<int>());	//operation
	PRINT_ELEMENTS(V1,"V1:    ");		//display the elements of V1
	PRINT_ELEMENTS(V2,"V2:    ");		//display the elements of V2
	PRINT_ELEMENTS(V3,"V1-V2: ");	//dispaly the resulted output
	V3.clear();
	cout<<endl<<endl;
	break;
	case '3':
	//transform  resulted element to list V3 after multiplication of each element 
	// - Multiply transformed values
	transform (V1.begin(),V1.end(),		//First source range
			back_inserter(V3),	//second source range
			bind2nd (multiplies<int>(),5)	//operation
					);
	PRINT_ELEMENTS(V1,"V1:   ");		//display the elements of V1
	PRINT_ELEMENTS(V3,"V1*5: ");	//dispaly the resulted output
	V3.clear();
	cout<<endl<<endl;
	break;
	case '4':
	transform (V2.begin(),V2.end(),		//First source range
			back_inserter(V4),	//second source range
			bind2nd (divides<float>(),5) //operation
				);
	//dispaly the resulted output
	PRINT_ELEMENTS(V2,"V2:   ");	
	PRINT_ELEMENTS(V4,"V2/5: ");	
	V4.clear();
	cout<<endl<<endl;
	break;

	case '5':
	PRINT_ELEMENTS(V2,"Before Replace of 5 in V2: ");	
    //replace value equal to 5 with 1
	replace_if (V2.begin(),V2.end(),                 //range
                   bind2nd(equal_to<int>() ,5) ,             //replace criterion
                   1) ;
	cout<<"After replace of 5 in V2:  ";
	for(pos=V2.begin();pos!=V2.end();++pos)
	{	
		cout<<*pos<<' ';
	}
	cout<<endl;
	break;
	case '6':
			PRINT_ELEMENTS(V1,"V1: ");	
	//remove all elements with values greater than 15
	V1.erase(remove_if(V1.begin(),V1.end(),		 //range
			 bind2nd(greater<int>() ,15)),             //remove criterion
				V1.end());
	cout<<"After removal of elements greater than 15"<<endl;
	PRINT_ELEMENTS(V1,"V1: ");	
	break;
	case '7':
	PRINT_ELEMENTS(V2,"Before Replace of 0 V2: ");	
	  //replace 0 for value less than 5
	replace_if(V2.begin(),V2.end(),               //range
		bind2nd(less_equal<int>() ,5),0);          //replace criterion            
	PRINT_ELEMENTS(V2," After Replace 0 for value < 5 V2: ");	
	break;		   			
	case '8':cout<<"********* LOGICAL OPERATIONS *********"<<endl;
			PRINT_ELEMENTS(va,"va:      ");	
			PRINT_ELEMENTS(vb,"vb:      ");						
	transform(va.begin(), va.end(),									vb.begin(), vc.begin(),
				logical_and<bool>());
	PRINT_ELEMENTS(vc,"va & vb: ");	
	transform(va.begin(), va.end(),							vb.begin(), vc.begin(),								logical_or<bool>());
	PRINT_ELEMENTS(vc,"va || vb:");	
	transform(va.begin(), va.end(),
			vc.begin(),
				logical_not<bool>());
	PRINT_ELEMENTS(vc,"!va:     ");	
	cout<<endl;
	break;	
	default:
	cout<<"You entered wrong option"<<endl;
	break;
			
	}	
	printf("Do you wish to continue[y/n]\n");
    //ch=(char)getche();
	cin>>ch;
	
    }while(ch=='Y' || ch=='y');
	cin.get();
}

Use cin ..

float f;
// input one value
cin >> f;  // then .. push_back(f)
int i;
// input one value
cin >> i; // then .. push_back(i)
This article has been dead for over six months. Start a new discussion instead.