Question: This is C++ code I am having a problem to running code I am getting an error so I need help to run the code.

This is C++ code I am having a problem to running code I am getting an error so I need help to run the code.

#include #include using namespace std;

void CheckValid(vector numberList) { int size = numberList.size(); cout << "List : "; for (int i = 0; i < size; ++i) { cout << numberList[i] << " "; } cout << " "; // checking size of the list is ==9 if (size != 9) { cout << "INVALID : lenght of list is not 9 "; return;

}

//checking for rang and duplicates int arr[10] = { 0 }; for (int i = 0; i < size; ++i) { // range check if(numberList[i] > 9 || numberList[i] < 1){ cout << "INVALID : " << numberList[i] << " Exist in list with is out of range "; return; }else{ // dupclicate check arr[numberList[i]]++; if (arr[numberList[i]] == 2) { cout << "INVALID :" << numberList[i] << " Exist more than once in the list "; return;

}

} } //if all is correct then it is valid cout << "List is VALID "; return;

}

//testing + main function int main() { vector numberList{ 1,2,3,4,5,6,7,8,9 }; checkValid(numberList); vector numberList1{ 0,2,3,4,5,6,7,8,9 }; checkValid(numberList1); vector numberList2{ 1, 2, 2, 4, 5, 6, 7, 8, 9 }; checkValid(numberList2); vector numberList3{ 1,2,2,4,5,6,7 }; checkValid(numberList3); vector numberList4{ 1,2,2,4,5,6,7,8,9,10 }; checkValid(numberList4); vector numberList5{ 1,2,3,4,5,6,7 }; checkValid(numberList5);

return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!