subject

Partially-filled Arrays Write the function rindby() which stands for remove mark>if not divisiby by. The function removes all elements from the array that are not evenly divisible by the argument n. You can find out if a number is evenly divisible by n using the remainder operator: % (there will be nothing left over).
The function returns the number of items removed or -1 if the array was originally empty.
The function takes 3 arguments:
the array of int that may be modified.
the size of the array (use size_t as the type)
the int n used to check for divisibility
Here are two short examples:
int a[] = {2, 3, 4, 5, 6};
size_t size = 5;
int removed = rindby(a, size, 2);
// removed->2, a = [2, 4, 6], size = 3
size = 0;
removed = rindby(a, size, 3);
// removed-> -1, no change otherwise
In the first case, the numbers 3 and 5 are removed because they are not divisible by 2. Only the numbers that are divisible by 2 are left in the array.
In the second, size has been set to , so the input array is empty and the function returns - 1.
Exam C++ Quick Reference
p1.cpp
1 #include // size_t for sizes and indexes
2 using namespace std;
3
4 WRITE YOUR FUNCTION BELOW THIS LINE
5 int rindby(int all, size_t& size, int number)
6 {
7 int result;
8 // Add your code here
9 return result;
10 }
11

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 01:30
Consider the following statements: #include #include class temporary { private: string description; double first; double second; public: temporary(string = "", double = 0.0, double = 0.0); void set(string, double, double); double manipulate(); void get(string& , double& , double& ); void setdescription(string); void setfirst(double); void setsecond(double); }; write the definition of the member function set() so that the instance variables are set according to the parameters. write the definition of the constructor so that it initializes the instance variables using the function set() write the definition of the member function manipulate() that returns a decimal number (double) as follows: if the value of description is "rectangle", it returns first * second if the value of description is "circle" it returns the area of a circle with radius first if the value of description is "cylinder" it returns the volume of a cylinder with radius first and height second. hint: the volume of a cylinder is simply the area of the circle at the base times the height. if the value of description is "sphere" it returns the volume of the sphere with radius first. otherwise it returns -1.0;
Answers: 1
question
Computers and Technology, 23.06.2019 15:30
1. ask the user how many questions are in the quiz. 2. ask the user to enter the key (that is, the correct answers). there should be one answer for each question in the quiz, and each answer should be an integer. e.g., 34 7 13 100 81 3 9 10 321 12 might be the key for a 10-question quiz. you will need to store the key in an array. 3. ask the user to enter the answers for the quiz to be graded. there needs to be one answer for each question. note that these answers do not need to be stored; each answer can simply be compared to the key as it is entered. 4. when the user has entered all of the answers to be graded, print the number correct and the percent correct. 5. add a loop so that the user can grade any number of quizzes with a single key. after the results have been printed for each quiz, ask "grade another quiz? (y/n)." note: you only have one array (the key). you are not creating a new key for each set of quiz answers.
Answers: 3
question
Computers and Technology, 24.06.2019 07:00
Selective is defined as paying attention to messages that are consistent with one’s attitudes and beliefs and ignoring messages that are inconsistent.
Answers: 1
question
Computers and Technology, 24.06.2019 12:50
Write a new lc-3 trap subroutine (i.e. a subroutine that will be invoked via the trap instruction) that will receive a numeric digit entered at the keyboard (i.e. an ascii character), echo it to the screen, and return in r0 the corresponding numeric value: so if the user types the digit '7', the character '7' will appear on the screen, but the value returned in r0 will be b0000 0000 0000 0111 (#7) you may not use any trap calls in your code - you must implement the "polling" code that interrogates the keyboard status and data registers. ; getnum_tsr ; a subroutine for obtaining a numeric value ; given ascii numeric digit input to keyboard. ; the numeric digit is echoed to the console (e.g. '7' = b0000 0000 0011 0111), ; but the value returned in r0 is the actual numeric value ; corresponding to the digit (e.g. b0000 0000 0000 0111 =
Answers: 3
You know the right answer?
Partially-filled Arrays Write the function rindby() which stands for remove mark>if not divisib...
Questions
Questions on the website: 13722363