ARDUINO
Create an array A with 11 elements (positive and negatives), then create two functions in Arduino as detailed below:
a. find () = find the intermediate value. Example if A = [ 2, 5, 3, 7, 8 ] the intermediate value =3
b. replace(int pos, int v) = given the position “pos”, replace it with the value “V”, then print the modified array
const int size = 11;
int temp = 0;
int n = 0, m=0;
int A[size] = {2,4,7,9,13,15,19,33,34,17,12};
void setup() {
Serial.begin(9600);
Serial.println("| Program to
find the intermediate value and replace the value for a given
position |");
find();
replace(6,10);
}
void loop() {
}
void replace(int pos,int v) {
A[pos] = v;
for(int i = 0; i < size; i++)
{
Serial.println(A[i]);
}
}
void find() {
m = sizeof(A);
n = m/2;
temp = A[n];
Serial.print("Intermediate value : ");
Serial.print(temp, DEC);
}
Get Answers For Free
Most questions answered within 1 hours.