DISPLAY ONLY EVEN OR ODD POSITIONS IN A ARRAY

This post is about how normal loops we use can be modified to access in differently .
DISPLAY ONLY EVEN POSITION CHARACTERS
Let consider a question asks to display only even position array elements then approach one uses is pass through each and every index and check whether,it is even or odd and then we display the element
Instead we can just use a while or for loop and change increment value
for example
int a[10]={0,1,2,3,4,5,6,7,8,9};
int i;
printf("even position numbers");
for(i=0;i<10;i+2)
{
printf("%d \n");
}
The output of this program will be
even position numbers
0
2
4
6
8
Similarly we can do it using a while loop
int i=0;
while(i<10)
{
printf("%d\n",a[i]);
i+=2;
}
The output will be same for this snippet also.
Even if we need only odd places we can just start from i=1
HOPE THIS HELPS.....................................
HAPPY READING........................................