Javatpoint Logo
Javatpoint Logo

7. C program to print the elements of an array present on even position

In this program, we need to print the element which is present on even position. Even positioned element can be found by traversing the array and incrementing the value of i by 2.

C program to print the elements of an array present on even position

In the above array, elements on even position are b and d.

ALGORITHM:

  • STEP 1: START
  • STEP 2: INITIALIZE arr[] = {1, 2, 3, 4, 5}
  • STEP 3: length= sizeof(arr)/sizeof(arr[0])
  • STEP 4: PRINT "Elements of given array present on even position:"
  • STEP 5: i=1. REPEAT STEP 6 and STEP 7 UNTIL i<length
  • STEP 6: PRINT arr[i]
  • STEP 7: i=i+2
  • STEP 8: RETURN 0.
  • STEP 9: END.

PROGRAM:

Output:

Elements of given array present on even position:
2
4
Next TopicC Programs





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA