#include <iostream>
int main() {
const int arraySize = 5;
int myArray[arraySize] = {1, 2, 3, 4, 5};
int elementToReplace = 3;
int replacementValue = 99;
// Find the index of the element to be replaced
int indexOfElement = -1;
for (int i = 0; i < arraySize; ++i) {
if (myArray[i] == elementToReplace) {
indexOfElement = i;
break;
}
}
// Replace the element if found
if (indexOfElement != -1) {
myArray[indexOfElement] = replacementValue;
// Display the updated array
std::cout << "Updated array: ";
for (int i = 0; i < arraySize; ++i) {
std::cout << myArray[i] << " ";
}
} else {
std::cout << "Element not found in the array.";
}
return 0;
}