@rahul_bansal you are just creating a single pair that is why it is showing this error.
pair<int,int>p defines a single pair for eg. (1,2)
to create an array of pairs you have to define a vector of pair i.e - vector<pair<int,int>>v;
and then we iterate over this vector.
vector<pair<int,int>>v defines an array of pairs for eg: (1,2),(3,4),(5,6) .
then you can easily use for looop to iterate over this array of pairs.
complete code can be written like this
vector<pair<int,int>>v;
int a,b;
for(int i=0;i<5;i++)
{
cin>>a>>b;
v.push_back(make_pair(a,b));
}
for(int i=0;i<5;i++)
{
cout<<v[i].first<<" "<<v[i].second<<endl;
}
Hope this helps