I need help. I have an assignment that says:
Asks the user to type 10 integers of an array and an integer v. The program must search if v is in the array of 10 integers. The program writes "v is in the array" if the integer v is in the array or "v is not in the array" if it's not.
My code seems fine, but it does not work properly. Please help.
Here's my code:
#include <iostream>
#include <conio.h>
#include <stdlib.h>
using namespace std;
int main () {
const int size = 10;
int vars[size],temp = 0,v = 0;
int boolean = 0,choice;
string check = "";
for(int x = 0; x<10; x++){
cout<<"Enter 10 Numbers: ";
cin>>vars[x];
}
do{
cout<<"Enter V variable :";
cin>>v;
for(int x = 0; x <10; x++)
{
temp = vars[x];
if(temp == v){
check = "v is in the array";
}
else{
check = "v is not in the array";
}
}
cout<<check;
cout<<"\nContinue ?"<<endl<<"[1]yes"<<endl<<"[2]no"<<endl;
cin>>choice;
system("cls");
for(int x = 0; x<10;x++){
cout<<"index" <<x<<" = "<<vars[x]<<endl;
}
} while(choice != 2);
return 0;
}