Array | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Array

How I can do array or program that ask the user to inter his name if his name is correct as array that i pointed on . will print to user a message ? https://www.sololearn.com/discuss/1285604/?ref=app

19th May 2018, 2:38 PM
Zeyad
Zeyad - avatar
4 Answers
0
I can write you a pseudo code since you didn't specify any language. # INITIALIZE YOUR ARRAY WITH NAMES YOU LIKE # ASK USER FOR INPUT # STORE THE INPUT AS STRING IN A VARIABLE # MAKE A FOR LOOP THAT LOOPS THROUGH THE ARRAY #MAKE A CONDITION check if the index is = to the name. Like if(array_index[x] == "stored_name") #THEN PRINT OUT A CUSTOM OUTPUT if you are using multiple names then switch would be better choice.
19th May 2018, 2:47 PM
Akib
Akib - avatar
0
Thanks bro
20th May 2018, 1:21 AM
Zeyad
Zeyad - avatar
0
Is going to be like that ? However THERE is an errors🐰
20th May 2018, 1:41 AM
Zeyad
Zeyad - avatar
0
#include <iostream> using namespace std; int main() { cout<<"i aupose youvarev my clasmate \n"; int g; cin>>g; string s[]={mkdad}; s=g; for(int d=0,d==s,d++) if (g==s){ cout<<"you are welcome\n"; } return 0; }
20th May 2018, 1:42 AM
Zeyad
Zeyad - avatar