Why we use v[i] just for showing output but not cin>>v[i] for taking input this point is not clear to me please explain, video reference(6:10)
Why can't we use cin>>v[i] for taking input
Hi divya
You can use v[i] when you have created a memory space in vector.
vectorv does not create a memory space and hence we use v.push_back(value) to create memory space and insert the value.
however
vectorv(n) creates a space for n values. We can use here v[i] for input also.
Hope it helps
1 Like
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.