subject

1)

Set numMatches to the number of elements in userValues (having NUM_VALS elements) that equal matchValue. Ex: If matchValue = 2 and userVals = {2, 2, 1, 2}, then numMatches = 3.

#include

int main(void) {
const int NUM_VALS = 4;
int userValues[NUM_VALS];
int i = 0;
int matchValue = 0;
int numMatches = -99; // Set numMatches to 0 before your for loop

userValues[0] = 2;
userValues[1] = 2;
userValues[2] = 1;
userValues[3] = 2;

matchValue = 2;

/* Your solution goes here */

printf("matchValue: %d, numMatches: %d\n", matchValue, numMatches);

return 0;
}

2)Write a for loop to populate array userGuesses with NUM_GUESSES integers. Read integers using scanf. Ex: If NUM_GUESSES is 3 and user enters 9 5 2, then userGuesses is {9, 5, 2}.

#include

int main(void) {
const int NUM_GUESSES = 3;
int userGuesses[NUM_GUESSES];
int i = 0;

/* Your solution goes here */

return 0;
}

3)Array testGrades contains NUM_VALS test scores. Write a for loop that sets sumExtra to the total extra credit received. Full credit is 100, so anything over 100 is extra credit. Ex: If testGrades = {101, 83, 107, 90}, then sumExtra = 8, because 1 + 0 + 7 + 0 is 8.

#include

int main(void) {
const int NUM_VALS = 4;
int testGrades[NUM_VALS];
int i = 0;
int sumExtra = -9999; // Initialize to 0 before your for loop

testGrades[0] = 101;
testGrades[1] = 83;
testGrades[2] = 107;
testGrades[3] = 90;

/* Your solution goes here */

printf("sumExtra: %d\n", sumExtra);
return 0;
}

4)Write a for loop to print all NUM_VALS elements of array hourlyTemp. Separate elements with a comma and space. Ex: If hourlyTemp = {90, 92, 94, 95}, print:

90, 92, 94, 95
Note that the last element is not followed by a comma, space, or newline.

#include

int main(void) {
const int NUM_VALS = 4;
int hourlyTemp[NUM_VALS];
int i = 0;

hourlyTemp[0] = 90;
hourlyTemp[1] = 92;
hourlyTemp[2] = 94;
hourlyTemp[3] = 95;

/* Your solution goes here */

printf("\n");

return 0;
}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 02:00
Think about some of the most memorable and forgettable games ever created. they can be games that were discussed in this unit or otherwise. what are some of the consistent factors that made certain games memorable to you? what were some of the consistent factors that made certain games forgettable to you? why? explain.
Answers: 1
question
Computers and Technology, 22.06.2019 09:40
It is vital to research each of the services you plan to disable before implementing any change, especially on critical machines such as the: a. servers in the test environment. b. domain controller and other infrastructure servers. c. desktops that have previously been attacked. d. desktops used by upper-level management.
Answers: 2
question
Computers and Technology, 24.06.2019 17:50
Create a class hand in its own module. one object of class hand represents a hand of cards and so one object stores a number of card objects. for this assignment you will submit three separate modules, one with the definition of class card, one with the definition of class hand and one with the main application that thoroughly tests class hand.class hand must contain the following four methods: 1) , numcardsinhand) takes an integer as parameter and initializes a hand object with numcardsinhand card objects inside it. these card objects are generated randomly. for simplicity, assume an infinite number of decks of cards.2) bjvalue(self) returns the blackjack value for the whole hand of cards3) ) returns a string containing all the cards in the hand4) hitme(self) adds one randomly generated card to the handcreate a main program in its own module that thoroughly tests class hand. you will have three modules/files to upload to your etudes assignment submission: card.py, hand.py and the module that contains your main program.two alternatives for extra credit - you cannot get credit for both! (+1 point): after you have thoroughly tested the class hand and all of its methods, add code to your main program that stores one hand object as a pickle file and reads it back into a new hand object. you are only eligible for this extra credit if class hand has all four of the methods above working.or(+2 points): after you have thoroughly tested the class hand and all of its methods, add code to your main program that stores one hand object as a text file on the disk and reads it back into a new hand object. you are only eligible for this extra credit if class hand has all four of the methods above working.notes: -start by making any and all modifications suggested by my comments to your previous submission of class card from assignment #6 "a robust card object"-once your class card is tested and working well, you will not make any further modifications to it for the purposes of class hand.-you can keep the test code for class card intact. if it is indented inside an if __name__ == "__main__", then it will not be executed when your main program's module imports it.-to save time, write and test one method for class hand at a time.-under no circumstances are you to attempt the extra credit until you are completely finished with writing and testing all the methods in class hand.
Answers: 3
question
Computers and Technology, 24.06.2019 19:50
How to unblock on chrome book? ?
Answers: 1
You know the right answer?
1)

Set numMatches to the number of elements in userValues (having NUM_VALS elements) th...
Questions
question
Social Studies, 18.09.2019 06:30
question
English, 18.09.2019 06:30
Questions on the website: 13722360