Print Alternate Elements In An Array

Introduction
  • The logic to print the alternate elements in C is very simple and we initially read the whole array elements and print the alternate elements, using a loop. 
Software Requirements
  • Turbo C++ OR C. 
Programming
  1. #include < stdio.h >   
  2. void main()  
  3. {  
  4.     int array[10];  
  5.     int i, j, temp;  
  6.     printf("enter the element of an array \n");  
  7.     for (i = 0; i < 10; i++) scanf("%d", & array[i]);  
  8.     printf("Alternate elements of a given array \n");  
  9.     for (i = 0; i < 10; i += 2) printf("%d\n", array[i]);  
  10. }  
Explanation
  • In the programming, given above, I have clearly explained how to print the alternate elements.

    programming 
Output

Output

Conclusion
  • Thus, it is printed and executed successfully.
Next Recommended Reading C Program To Print Pascal Triangle