Assign numMatches with the number of elements in userValues that equal matchValue. userValues has NUM_VALS elements....
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Assign numMatches with the number of elements in userValues that equal matchValue. userValues has NUM_VALS elements. Ex: If userValues is {2, 1, 2, 2} and matchValue is 2, then numMatches should be 3. Your code will be tested with the following values: matchValue: 2, userValues: {2, 1, 2, 2} (as in the example program above) matchValue: 0, userValues: (0, 0, 0, 0} matchValue: 10, userValues: {20, 50, 70, 100} Notes) 1 #include <stdio.h> 2 1 test 3 int main(void) { const int NUM_VALS int userValues [NUM_VALS]; int i; int matchValue; int numMatches = -99; // Assign numMatches with @ before your for loop passed 4 = 4; All tests 8 passed 10 scanf("%d", &matchValue); for (i = 0; i < NUM_VALS; ++i) { scanf ("%d", &(userValues [i])); } 12 %3D 13 16 /* Your solution goes here */ 17 18 printf("matchValue: %d, numMatches: %d\n", matchValue, numMatches); 19 20 return 0; 21 } 111 1 111 111 22 Write a for loop to print all elements in courseGrades, following each element with a space (including the last). Print forwards, then backwards. End each loop with a newline. Ex: If courseGrades = {7, 9, 11, 10}, print: 7 9 11 10 10 11 9 7 Hint: Use two for loops. Second loop starts with i = NUM_VALS - 1. (Notes) Note: These activities may test code with different test values. This activity will perform two tests, both with a 4-element array (int courseGrades[4]). See "How to Use zyBooks". Also note: If the submitted code tries to access an invalid array element, such as courseGrades[9] for a 4-element array, the test may generate strange results. Or the test may crash and report "Program end never reached", in which case the system doesn't print the test case that caused the reported message. 1 #include <stdio.h> 3 int main(void) { const int NUM_VALS = 4; int courseGrades [NUM_VALS]; int i; 1 test passed 4. 5 6 7 All tests for (i = 0; i < NUM_VALS; ++i) { scanf("%d", &(courseGrades[i])); } 8 passed 10 11 12 /* Your solution goes here */ 13 14 return 0; 15 } Assign numMatches with the number of elements in userValues that equal matchValue. userValues has NUM_VALS elements. Ex: If userValues is {2, 1, 2, 2} and matchValue is 2, then numMatches should be 3. Your code will be tested with the following values: matchValue: 2, userValues: {2, 1, 2, 2} (as in the example program above) matchValue: 0, userValues: (0, 0, 0, 0} matchValue: 10, userValues: {20, 50, 70, 100} Notes) 1 #include <stdio.h> 2 1 test 3 int main(void) { const int NUM_VALS int userValues [NUM_VALS]; int i; int matchValue; int numMatches = -99; // Assign numMatches with @ before your for loop passed 4 = 4; All tests 8 passed 10 scanf("%d", &matchValue); for (i = 0; i < NUM_VALS; ++i) { scanf ("%d", &(userValues [i])); } 12 %3D 13 16 /* Your solution goes here */ 17 18 printf("matchValue: %d, numMatches: %d\n", matchValue, numMatches); 19 20 return 0; 21 } 111 1 111 111 22 Write a for loop to print all elements in courseGrades, following each element with a space (including the last). Print forwards, then backwards. End each loop with a newline. Ex: If courseGrades = {7, 9, 11, 10}, print: 7 9 11 10 10 11 9 7 Hint: Use two for loops. Second loop starts with i = NUM_VALS - 1. (Notes) Note: These activities may test code with different test values. This activity will perform two tests, both with a 4-element array (int courseGrades[4]). See "How to Use zyBooks". Also note: If the submitted code tries to access an invalid array element, such as courseGrades[9] for a 4-element array, the test may generate strange results. Or the test may crash and report "Program end never reached", in which case the system doesn't print the test case that caused the reported message. 1 #include <stdio.h> 3 int main(void) { const int NUM_VALS = 4; int courseGrades [NUM_VALS]; int i; 1 test passed 4. 5 6 7 All tests for (i = 0; i < NUM_VALS; ++i) { scanf("%d", &(courseGrades[i])); } 8 passed 10 11 12 /* Your solution goes here */ 13 14 return 0; 15 }
Expert Answer:
Related Book For
Mathematical Statistics with Applications in R
ISBN: 978-0124171138
2nd edition
Authors: Chris P. Tsokos, K.M. Ramachandran
Posted Date:
Students also viewed these programming questions
-
In each of the following, find the number of elements in the resulting sample space. (a) If a die is rolled five times, how many elements are there in the sample space? (b) If 13 cards are selected...
-
Which of the following properties returns the number of elements in an array? a. Length b. Size c. Elements d. Indexes
-
We were able to determine the number of elements in the union of two sets with the formula n(A B) = n(A) + n(B) - n(A B). Can you determine a formula for finding the number of elements in the union...
-
Given the data (a) Calculate (2.8) using Newtons interpolating polynomials of order 1 through 3. Choose the sequence of the points for your estimates to attain the best possible accuracy. (b) Utilize...
-
A particle moves according to a law of motion s = f(t), t 0, where is measured in seconds and in feet. (a) Find the velocity at time t. (b) What is the velocity after 3 s? (c) When is the particle...
-
Some pipe organs create sounds lower than humans can hear. This "infrasound" can still create physical sensations. What is the fundamental frequency of the sound from an open-open pipe that is 32...
-
The following are methods used to evaluate public health data and scientifc evidence except a. Use of standard criteria by experts b. By combining the results of multiple scientifc studies that are...
-
Dillard Travey receives 5,000 tripods annually from Quality Suppliers to meet his annual demand. Dillard runs a large photographic outlet, and the tripods are used primarily with 35-mm cameras. The...
-
22. Assume that the following current asset and current liability accounts apply to the Harden Company for the years 2021 and 2022 (note: the ??? in the table is a figure that you must determine)....
-
Arndt, Inc., reported the following for 2024 and 2025 ($ in millions): a. Expenses each year include $30 million from a two-year casualty insurance policy purchased in 2024 for $60 million. The cost...
-
When current in a coil changes from 5 A to 2 A in 0.1 s, an average voltage of 50 V is produced. The self-inductance of the coil is (a) 0.67 H (b) 1.67 H (c) 3 H (d) 6 H
-
Why do you think the Milgram experiment is so controversial? What sorts of effects might the experiment have had on participants? Do you think the experiment would have had similar results if it had...
-
Discuss the main reasons for adjusting entries, and list the main types of adjusting entries.
-
What are the major categories of psychological disorders?
-
Explain the purpose of consolidation eliminating entries.
-
In what ways do societal expectations, expressed by television shows and commercials, contribute to both obesity and excessive concern about weight loss? How could television contribute to better...
-
2. Two urns contain white and black balls: Urn 1 contains 10 black balls and 5 white balls, Urn 2 contains 8 black balls and 2 white balls. Two balls are drawn randomly from urn 1, and these two...
-
What types of inventory issues Starbucks might reflect upon at the end of each year? The mission of Starbucks is to inspire and nurture the human spiritone person, one cup, and one neighborhood at a...
-
Let U1 and U2 be independent random variables. Suppose that U1 is X2 with v1 degrees of freedom while U = U1 + U2 is chi-square with v degrees of freedom, where v > v1. Then prove that U2 is...
-
Find the mean and variance of F (n1, n2) random variable.
-
Air pollution in large US cities is monitored to see whether it conforms to requirements set by the Environmental Protection Agency. The following data, expressed as an air pollution index, give the...
-
Define internal combustion engine and explain how it is different from external combustion engines?
-
In an air standard Otto cycle, the pressure and temperature at the start of compression stroke are 1 bar and \(30^{\circ} \mathrm{C}\), respectively. The temperature at the end of compression is...
-
In I.C. engines, power developed inside the cylinder is known as: (a) Brake horse power (b) Indicated horse power (c) Pumping power (d) None of the above
Study smarter with the SolutionInn App