How to find if a value is included in an array in C++?

0 votes
asked Jul 22, 2019 by hezigonic (140 points)
I would like a function that finds if a value is included in an array.

For example, if "insertTextHere" is in the chosen array, then it should return true.

If "insertTextHere" is NOT in the chosen array, then it should return false.

Thanks.

1 Answer

0 votes
answered Jul 23, 2019 by siege

I KNOW THE SAME IN JAVA AND I THINK IT IS SLIGHTLY SIMMILAR IN C++ TOO SO YOU CAN USE THIS METHOD.

You can return th elements in the array to see the values in them.

Use loop to circle through all the elements in the array.

Make the loop to check the element for the one you are searching for using if method.

If boolean is true then return them.

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...