Integers – Equal to Index

The program must accept N integers and print the integers which are equal to their index value as the output. If there is no such integer, the program must print -1 as the output.

Input :

6
5 4 2 3 6 5

Output :

2 3 5

Explanation:
Here 2, 3 and 5 are the integers equal to their index value.

Here are the various methods and logic.

C++

Python :

C :

#C code by Agent Cherry
#C code by Agent Cherry
#C code by Agent Falcon

Leave a Reply

Your email address will not be published. Required fields are marked *

More posts. You may also be interested in.