I wanted to ask that in the given video bhaiya has traversed through the vector using the for(int i=0;i<v.size();i++)
{
cout<<v[i]<<" ";}
but why can’t we use the foreach loop to traverse through the vector as it is producing errors
I wanted to ask that in the given video bhaiya has traversed through the vector using the for(int i=0;i<v.size();i++)
{
cout<<v[i]<<" ";}
but why can’t we use the foreach loop to traverse through the vector as it is producing errors
@jsn853 in c++ you can iterate vectors like this also for(int i:v)cout<<i<<" ";
if your doubt is cleared dont forget to mark it as resolved and hit 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.