- 1
how to printf only number in odd index/array?
example: input 1 2 3 4 5 //a[0] a[1] a[2] a[3] a[4] output 2 4 // because 2 is in index a[1] and 4 is in index a[3] which is odd number
1 Antwort
+ 1
for(i=1;i<arsize;i+=2)
cout<<ar[i];
OR
for(i=0;i<arsize;++i)
if(i%2)
cout<<ar[i];