5 10 20 30 40 50 30
2
void question5_find_position() {
int arr[] = {12, 45, 67, 23, 89};
int size = 5;
int searchElement = 67;
int position = -1;
for(int i = 0; i < size; i++) {
if(arr[i] == searchElement) {
position = i;
break;
}
}
if(position != -1) {
cout << "Element found at index: " << position << endl;
} else {
cout << "Element not found" << endl;
}
}
void question5_find_position() {
int arr[] = {12, 45, 67, 23, 89};
int size = 5;
int searchElement = 67;
int position = -1;
for(int i = 0; i < size; i++) {
if(arr[i] == searchElement) {
position = i;
break;
}
}
if(position != -1) {
cout << "Element found at index: " << position << endl;
} else {
cout << "Element not found" << endl;
}
}