I have the following verification code to know if a certain number belongs to a vector. I could not think of a more accurate way to make the program say that the number DOES NOT belong to the vector, just that it belongs and what its position within it. Can you help me get the message "number is not part of the vector" after verification? (in a leaner way)
Code:
#include <iostream>
using namespace std;
int main()
{
int vetor[5] = {10, 20, 30, 40, 50};
int N;
cout << "digite um numero: " << endl;
cin >> N;
for(int i = 0; i <=4; i++)
{
if(N == vetor[i])
cout << "O numero faz parte do vetor e está na " << i+1 << " posicao" << endl;
}
return 0;
}