ritesh1340

auto command generating garbage value for the last output

Jan 1st, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.34 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5.  
  6.     vector < int > v ( 5,0 );
  7.  
  8.     for ( int i=0 ; i<5 ; i++ ) v[i]=i+1;
  9.  
  10.     cout<<"Now Printing elements using the auto command : \n";
  11.  
  12.     /*for ( int i=0 ; i<5 ; i++ )
  13.         cout<<v[i]<<' ';*/
  14.  
  15.     for ( auto i:v )
  16.         cout<<v[i]<<" ";
  17.  
  18.     return 0;
  19. }
Add Comment
Please, Sign In to add comment