Answered You can hire a professional tutor to get the answer.
I am trying to get five unique names, but I can't make any sense of the error within my coding. The output is always wrong.
I am trying to get five unique names, but I can't make any sense of the error within my coding. The output is always wrong.
#include <iostream>
#include <string>
using namespace std;
int main() {
int name=0;
string arr[5];
string NameEntered;
cout <<"Enter 5 different names..."<< endl;
while (name<5){
cout <<"Enter name # "<<(name+1)<<": ";
cin >> NameEntered;
cout << NameEntered << endl;
bool status =false;
break;
for(int i=0; i<name; i++) {
if(NameEntered == arr[i]) {
status = true;
break;
}
}
if(status) {
cout << "You already entered that name!" << endl;
}
else{
arr[name] = NameEntered;
name++;
}
}
cout << "Here are the names: " << endl;
for(int i=0; i<5; i++)
cout << arr[i] << endl;
return 0;
}
=================== MISMATCH FOUND ON LINE 0003: ===================
ACTUAL : Here~are~the~names:
EXPECTED: Enter~name~#~2:~Carol