How to check if an element exists in an array or not? (C++) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How to check if an element exists in an array or not? (C++)

What i wanna do is>> Given n = 5 Given input --> 2 3 2 2 3 array [n] Cin > input Check(if element in array) If not, then store the value in array.. Else..continue For example: first input> 2..and the array is empty..so 2 not in array..then store it in array.. // Only store unique values.. I am having problem at the if statement..how can i check the value already exists or not?

13th May 2020, 7:30 AM
Amit Dubey
Amit Dubey - avatar
2 Answers
13th May 2020, 8:25 PM
Ahmed Mostafa
Ahmed Mostafa - avatar
0
it would be easier if you shared the code you already have. may i suggest using a vector instead? if so here goes something i put together https://code.sololearn.com/c95rHOTTniLs/?ref=app
13th May 2020, 8:39 PM
Lee Howard
Lee Howard - avatar