main.m270 chars15 lines
First, we define the vector x
containing values to be examined. We then initialize the variables count
and y
.
We use a for
loop to iterate over each element of x
, checking if each element lies within the specified range using a conditional statement (if
statement with &&
operator).
If the element is within the specified range, we increment count
and add the element to the vector y
.
Finally, we display the number of elements found within the range and display the final vector y
.
gistlibby LogSnag