subject
Engineering, 07.03.2020 06:29 jfarley259

Write a for loop to determine the number of elements in vector userValuess that equal matchValue. Assign the number of matching elements to numMatches. Use NUM_VALS to determine how many elements are in the vector. Ex: numMatches is 3 if matchValue = 2 and userVals = {2, 2, 1, 2}.

Sample program:

#include
#include
using namespace std;

int main() {
const int NUM_VALS = 4;
vector userValues(NUM_VALS);
int i = 0;
int matchValue = 0;
int numMatches = 0;

userValues. at(0) = 2;
userValues. at(1) = 2;
userValues. at(2) = 1;
userValues. at(3) = 2;

matchValue = 2;

cout << "Elements equal to " << matchValue << ": " << numMatches << endl;

return 0;
}

ansver
Answers: 3

Another question on Engineering

question
Engineering, 03.07.2019 15:10
Two flowing streams of argon gas are adiabatically mixed to form a single flow/stream. one stream is 1.5 kg/s at 400 kpa and 200 c while the second stream is 2kg/s at 500 kpa and 100 ? . it is stated that the exit state of the mixed single flow of argon gas is 150 c and 300 kpa. assuming there is no work output or input during the mixing process, does this process violate either the first or the second law or both? explain and state all your assumptions.
Answers: 1
question
Engineering, 04.07.2019 18:20
Find the minimum film thickness for a journal bearing with the data below. shaft diameter, d-50 mm, clearance ratio, cdratio? 0.001, shaft speed, n 2000 rpm; bearing length. i 200 mm; eccentricity ration, ? -0.55. ( note, cdratio-ca/d) the minimum film thickness is um
Answers: 2
question
Engineering, 04.07.2019 19:20
Air enters a horizontal, constant-diameter heating duct operating at steady state at 290 k, 1 bar, with a volumetric flow rate of 0.25 m°/s, and exits at 325 k, 0.95 bar. the flow area is 0.04 m2. assuming the ideal gas model with k = 1.4 for the air, determine (a) the velocity at the inlet and exit, each in m/s, and (c) the rate of heat transfer, in kw flow rate, in kg/s, (b) the mass kg 0.3
Answers: 2
question
Engineering, 06.07.2019 03:20
Aparticle moves along a straight line such that its acceleration is a=(4t^2-2) m/s, where t is in seconds. when t = 0, the particle is located 2 m to the left of the origin, and when t = 2, it is 20 m to the left of the origin. determine the position of the particle when t=4s.
Answers: 1
You know the right answer?
Write a for loop to determine the number of elements in vector userValuess that equal matchValue. As...
Questions
question
Mathematics, 08.04.2021 06:50
question
Mathematics, 08.04.2021 06:50
Questions on the website: 13722367