Print alternate elements of an array
Submissions: 29397   Accuracy:


  Difficulty: School   Marks: 0
*School Problem's Submission isn't counted in score!

You are given an array A of size N. You need to print elements of A in alternate order.

Input Format:
The first line of input contains T denoting the number of testcases. T testcases follow. Each test case contains two lines of input. The first line contains N and the second line contains the elements of the array.

Output Format:
For each testcase,
print the alternate elements of the array(starting from index 0).

Your Task:
Since this is a function problem, you just need to complete the provided function void print(int ar[],int n)

1 <= T <= 200
1 <= N <= 105
1 <= Ai <= 105


1 2 3 4
1 2 3 4 5

1 3
1 3 5

Testcase1: print 1, then 3.
Testcase2: print 1, then 3, then 5.

** For More Input/Output Examples Use 'Expected Output' option **

Author: sumit.chauhan

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Need help with your code? Please use, generate link and share the link here.

to report an issue on this page.