rite a program that examines each element of a vector using a for loop. If the element is positive its value is doubled. If the element is negative its value is tripled. Use the ctor v given: = [11 -10 -2 -9 -7 15 11 -1 19 -9 31 13 14 -553 10 11]
Q: Thank your for the code!
A: Define a function named create_words_list_dictionary (words_list) which takes a list of words as a…
Q: What are the benefits of using a function?
A: FUNCTION: Function is basically the modules that are self contained in the context that these…
Q: What exactly is variable initialization and why is it necessary
A: In Step 2, I have provided explanation In Step 3 , I have provided JAVA PROGRAMS for better…
Q: PROBLEM: Write a program that computes for the Electric Field and Electric Potential at a given…
A: - We need to create a C++ program to calculate the electric field based on the distances.
Q: In C++ Programming, Declare and initialize a double variable payRate to 12.50.
A: C++ is a general-purpose programming language that was developed by Bjarne Stroustrup as an…
Q: The following formula can be used to determine the distance an object falls due to gravity in a…
A: NOTE: SINCE THE LANGUAGE OF THE CODE IS NOT MENTIONED, I HAVE USED C++ FOR THE SOLUTION. Define…
Q: Write the following function: Name: CylinderVolume Parameters: r (int), h (double) Calculate and…
A: C++ Program for above : #include <bits/stdc++.h> using namespace std; double…
Q: The Issue: You have a function that accepts a variety of parameters. It is impractical to provide…
A: Dictionaries can be passed as function arguments, just like any other variable.
Q: A variable x is assigned a NULL value. The return value from the function is.null(x) will be a. TRUE…
A: this function is used in PHP is_null it Finds whether a variable is NULL or not Syntax…
Q: The correct statements are: For L = 0, L = {e} For L = {}, L* = {e} L+ = LL* OL+ OL* = LL+
A: The query seems to be about formal language theory and properties related to the Kleene closure and…
Q: nductor with a radius (r) and a charge Q, depending upon the following cases: Calculate the…
A: We need to read in the values of Q, r and d ,then compute and display the result as per the given…
Q: In C++ the parameters of a function are specified before the function name O True False
A: answer is
Q: Q4: the volume of a cylinder is given by the formula: V =n r²L Where r is the cylinder's radius and…
A: Types of functions in programming language: 1. Without arguments, no return value 2. Without…
Q: 2. You are one of the gym instructors at AmiKenoMota. You decide to provide a customized diet and…
A: Note - As you haven't mentioned specific programming language to write code, I have written the code…
Q: :The parameters specified in the function heading are known as formal parameters value parameters…
A: Given:
Q: in c++ void check_palindrome() - to check whether the given number by user is palindrome or not.…
A: Program Approach - Use the header files as per requirement. Define the function named…
Q: Detect Even/Odd Write a function with no parameters, even_or_odd() in Python Specifications:…
A: To check if a number is even or odd using mod(%) operator. The modulo operator returns the remainder…
Q: python code Write a function called showNumbers that takes a parameter called limit. It should…
A: The required function using python code and along with comments is : def showNumbers(limit):…
Q: Evaluate the following expressions and determine the value of all variables, based on the above…
A: The given expressions and the value of allvariables
Q: wo question in code ple
A: Solution:: 1: public class LoanAccount { // properties private double…
Q: A(n)_is a variable that is used within a function. Select one: O a.operator O b.property O…
A: Given:-
Q: Convert radians into degrees Write a function in Python that accepts one numeric parameter. This…
A: Here is your solution -
Q: Write a program to calculate and display the sum of the following series using for loop.…
A: This code calculates sum of the given series by using for loop. It asks the user to enter the value…
Q: For the following code: for ( a = 1, b = 5, c = 3; a < 4; a++, b++ ) { c = a * b +…
A: In this code snippet, a for loop is used to iterate and perform calculations on three variables: a,…
Q: ROBLEM: Write a program that computes for the Electric Field and Electric Potential at a given point…
A: C++ code to calculate the electric field and electric potential
Q: Where is the void function for circumference
A: We need to write the void function for circumference. In Python, all functions return value whether…
Q: he parameters
A: A parameter is an optional list of parameters that you define both pass information into the…
Q: Write the pseudocode for a function that should accept a test score as an argument and return a…
A: define getLetterGrade(score): receive score from keyboard if score >= 90: return "A" if 90 >…
Q: As one variable goes up, the other variable goes down” is a description of:
A: Correlation is a method of statistical measure which is expressing the extent to of two variables…
Q: TRUE OR FALSE Variables declared inside the function are local to that function.
A: 1) Variable is a name assign to a storage area that the program can manipulate. 2) Local Variable is…
Q: Variables of type single occupy half the memory of variables of type double, but they have lower…
A: Variables of type single occupy half the memory of variables of type double, but they have lower…
Q: USE PYTHON Source: en.wikipedia.org/wiki/Camel_case In some languages, it’s common to use…
A: Program Approach: Create a function camel_to_snake which takes a camel case string var_name as…
Q: The parameters passed to function are .called formal parameters True O Fales O
A: Given statement is, The parameters passed to function are .called formal parameters .
![Write a program that examines each element of a vector using a for loop. If the element is positive its value is doubled. If the element is negative its value is tripled. Use the
vector v given:
v = [11 -10 -2 -9 -7 15 11 -1 19 -9 3 1 13 14 -5 53 10 11]](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F7bc3513b-8f03-48ef-b371-8a0feb49c7bb%2F0212d9cb-65d3-4669-9a22-1dc9be96b55a%2Fjw48ij_processed.jpeg&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 4 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
- Write a for loop to print all NUM_VALS elements of vector courseGrades, following each with a space (including the last). Print forwards, then backwards. End with 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 = courseGrades.size() - 1 (Notes)C++ without using std:: Note: These activities may test code with different test values. This activity will perform two tests, both with a 4-element vector (vector<int> courseGrades(4)). See "How to Use zyBooks".Also note: If the submitted code has errors, 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. #include <iostream>#include <vector>using namespace std; int main() { const int NUM_VALS = 4; vector<int> courseGrades(NUM_VALS); int i; for (i = 0; i < courseGrades.size(); ++i) { cin >>…import numpy as np import torch import matplotlib.pyplot as plt Quiz Preparation Question 1. Write a function that generates a random tensor of n x n (n is the input). The output is the mean of the tensor. = 2, 4, 8, 16, ... 1024 and generate a vector 2. Write a code (for loop) that call that calls the function above with n = M(n). Plot the vector as a function of the log of n. 3. Given an n x m array write a code that replaces every element that is larger than 0.5 with 0.5. 4. The second derivative of a function can be approximated by the finite difference 1 ƒ"(x₂) = 73 (ƒ(£;+1) — 2ƒ(x;) + f(x;-1)) Given a vector f with values f = [f(xo),..., f(n) write a code that computes the approximation to f"(x) 5. The power method is a method to compute the largest eigenvalue of a matrix. Your google search is using this method every time you perform a google search. The method consists of the iteration Vj+1 = Av; || Avi|| where v; is a vector with chosen as a random vector, and A is the matrix…Write a for loop to print all NUM_VALS elements of vector courseGrades, following each with a space (including the last). Print forwards, then backwards. End with 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 = courseGrades.size() - 1 (Notes)C++Note: These activities may test code with different test values. This activity will perform two tests, both with a 4-element vector (vector<int> courseGrades(4)). See "How to Use zyBooks".Also note: If the submitted code has errors, 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. #include <iostream>#include <vector>using namespace std; int main() { const int NUM_VALS = 4; vector<int> courseGrades(NUM_VALS); int i; for (i = 0; i < courseGrades.size(); ++i) { cin >> courseGrades.at(i);…
- numStudents is read from input as the number of input values in the vector that follow. Use two for loops to output all numStudents elements of vector walkingLogs that are: even integers • odd integers ● For both loops, follow each element with a space, including the last element, and end with a newline. Ex: If the input is 8 11 30 70 39 69 29 138 162, then the output is: 30 70 138 162 11 39 69 29 3 using namespace std; 4 5 int main() { 6 7 8 9 10 11 12 13 14 15 16 17 18 19} int numStudents; int i; cin >> numStudents; vector walkingLogs (numStudents); for (i = 0; i > walkingLogs.at(i); } * Your code goes here */ return 0; ►numMembers is read from input as the size of the vector. Then, numMembers elements are read from input into the vector bikingRoster. Use a loop to access each element in the vector and if the element is less than averageMembers, output the element followed by a space. Ex: If the input is 8 193 102 3 86 38 161 169 153, then the output is: Average: 113 Numbers less than average: 102 3 86 38 1 #include 2 #include 3 using namespace std; 4 5 int main() { 6 7 unsigned int i; 8 double averageMembers; 9 int sumElementData = 0; 10 11 12 13 14 15 16 int numMembers; cin >> numMembers; vector bikingRoster (numMembers); for (i = 0; i > bikingRoster.at(i); sumElement Data + bikingRoster at(i):4. Create a vector (name the vector as "A") with random 12 values from the interval [1, 40] and use for loop to find the greatest element of the vector (name the element as maxA). Then, use while loop to find the smallest element of the vector (name the element as minA). Define a vector B, where B is the vector A sorted in descending order. Define a vector C, where C is the vector A sorted in ascending order. For the results (output) show the vectors A, B, C, maxA, and minA. [20 points]
- 2. Replace the even locations in the vector m= [7 9 2 4 5 8 10 3] with the following set of elements [1036 7] Your answerin c++ languagee pleaseee6. A three-dimensional vector has the form: A = (x, y, z) can be represented as: given the vectors: Example: Their sum is:Example: struct VECTOR { double x; double y; double z; }; A = ( a, b, c ) (5, 6, 2) and B = ( d, e, f ) (3, 1,9) A + B = ( a + d, b + e, c + f ) (5 + 3, 6 + 1, 2 + 9) = (8, 7,11)A B = a x d + b x e + c x f Their scalar product is:(result is a scalar) example: 5 x 3 + 6 x 1 + 2 x 9 = 39 Write the complete definition code for the functions: a. calc_sum computes and returns the sum of two vectors b. scalar_prod computes and returns the scalar product of two vectors
![C++ for Engineers and Scientists](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)
![C++ for Engineers and Scientists](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)