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, 04.07.2019 18:10
Afull journal bearing has a journal diameter of 27 mm, with a unilateral tolerance of -0.028 mm. the bushing bore has a diameter of 27.028 mm and a unilateral tolerance of 0.04 mm. the l/d ratio is 0.5. the load is 1.3 kn and the journal runs at 1200 rev/min. if the average viscosity is 50 mpa-s, find the minimum film thickness, the power loss, and the side flow for the minimum clearance assembly.
Answers: 1
question
Engineering, 04.07.2019 18:10
Calculate the bore of a cylinder that has a stroke of 18 inches and an extension time of 6 seconds at a flow rate of 4 gal/min.
Answers: 3
question
Engineering, 04.07.2019 18:10
The flow rate of air through a through a pipe is 0.02 m5/s. a pitot static tube is placed in the flow. the radius of the pitot static tube is 1 mm. assuming the flow to be steady and the air to be at 300k, calculate the difference in total and static pressure if the diameter of the pipe is: (a) d 0.1 m d 0.05 m (c) d 0.01 m
Answers: 2
question
Engineering, 04.07.2019 18:20
Determine the damped natural frequencies and the steady state response of a decoupled damped forced two degrees of freedom system. 10ä1 + 2q1 20q1 10 cos t; 10q2 +4q2 + 40q2 10 cos t
Answers: 3
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, 19.01.2021 20:20
question
Health, 19.01.2021 20:20
question
Arts, 19.01.2021 20:20
question
Mathematics, 19.01.2021 20:20
question
Mathematics, 19.01.2021 20:20
Questions on the website: 13722360