Leaderboard
Showing:
C++ Array (print an element) | Set 2
School Accuracy: 62.14% Submissions: 103 Points: 0

Given an array A[] of N integers and an index Key. Your task is to print the element present at index key in the array.

 

Example 1:

Input:
5 2
10 20 30 40 50
Output:
30

 

Example 2:

Input:
7 4
10 20 30 40 50 60 70
Output:
50

 

Your Task:  
You don't need to read input or print anything. Your task is to complete the function findElementAtIndex() which takes the array A[], its size N and an integer Key as inputs and returns the element present at index Key.


Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)

 

Constraints:
1 ≤ N ≤ 100
0 ≤ Key ≤ N - 1

1 ≤ A[i] ≤ 100

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

C++ Array (print an element) | Set 2

Output Window