Hi Guys i just want to ask How can I check for an element of the kind string data type in arrya thst i have.. and if it not tel | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Hi Guys i just want to ask How can I check for an element of the kind string data type in arrya thst i have.. and if it not tel

3rd Jul 2022, 2:16 PM
khalid Abd allmahmoud
khalid Abd allmahmoud - avatar
4 Answers
+ 2
In R language, you can check if a vector contains a specific element, like this: names <- c("Amy", "Penny", "Bernadette") print(is.element("Penny", names)) #TRUE print(is.element("Sheldon", names)) #FALSE
7th Jul 2022, 8:08 AM
Tibor Santa
Tibor Santa - avatar
+ 1
C++ or R? Please tag ⭐⭐⭐ONLY⭐⭐⭐ the relevant programming language. Give an example array.
3rd Jul 2022, 2:22 PM
Lisa
Lisa - avatar
0
Ok... look i mean something like let take c++ as example ok!... #include <iostream> using namespace std; int main() { string class1[5] ={"class1","khalid","ali","maab","hibe"}; string class2[5] ={"class2","musa","abdalh","noor","Ahmed"}; string class3[5] ={"class3","noor","hussan","mhmmed","mahmoud"}; // now i want the user to input his // value (his name that he want to // know if in the dataset or not) string name; cin >> name; if(name == "khalid"){ cout << elex27[0]; // i can use if statmant like now // for any arrya thar i have // but i can do that if i have lot of arrya } return 0; } So i need some of function or any method can be helpful but by c++ or r
3rd Jul 2022, 4:10 PM
khalid Abd allmahmoud
khalid Abd allmahmoud - avatar
0
I find that is easy by python...it can be like : class1 = [1,2,3] x="what the user inter" if x in class1 print ("do something")
3rd Jul 2022, 4:15 PM
khalid Abd allmahmoud
khalid Abd allmahmoud - avatar