Write a function curve that accepts a vector v of double and returns vector after processing it. First the function calculates the average of the vector and the function should then process the vector by adding the average to each element of the vector and then dividing by 2 the function should then return processed vector.
Function is like this:
vector<double> fun(vector<double>g){
double sum=0;
for (int i = 0; i< g.size(); i++)
{sum+=g[i];}
double avg = sum/g.size();
for (int i = 0; i< g.size(); i++)
{g[i]+=avg; g[i]/=2;}
return g;
}
Write a function curve that accepts a vector v of double and returns vector after processing...
C++ //get_letter_grade.h /* Write a function gpa_to_letter_grade that returns a string and accepts a double gpa parameter */ //get_letter_grade.cpp /* Write function code for gpa_to_letter_grade that returns a string and accepts a double gpa parameter YOU MUST USE A SWITCH STATEMENT Given a double 3.5 returns the string A TIP: You'll have to convert the double to an int using multiplication Table 3.5 to 4 returns an A 3.0 to 3.49 returns a B 1.7 to 2.99 returns a C...
Write a program with a function that accepts a string as an argument and returns a copy of the string with the first character of each sentence capitalized. For instance, if the argument is “hello. my name is Joe. what is your name?” the function should return the string “Hello. My name is Joe. What is your name?” The program should let the user enter a string and then pass it to the function. The modified string should be displayed.
Written in C++ (On CodeStepbyStep) Write a function named mean that accepts as a parameter a reference to a Vector of real numbers, and returns the arithmetic mean (average) of the integers in the vector as a real number. For example, if the vector passed contains {2.0, 4.5, 6.5, 1.0}, your function should return 3.5. If the vector is empty, return 0.0. Do not modify the vector that is passed in.
Write a function named squareAndSort(). This function should take a reference to a vector of <double> values. The function should square each of the values in the vector and then sort the vector in ascending order. Since the vector is passed by reference, this function does not need to return anything, so it will be a void function.
Please write the code using matlab
1) i. Create an anonymous function named optimist, that accepts a single variable as input i Create a row vector Tthat represents the number of seconds in two minutes, starting ii. Call the function optimist on the vector T, store the result in variable R1 and returns the double of that variable from one and ending at a hundred and twenty v. Create an anonymous function named pessimist, that accepts a single variable as...
1. Write a function called ordinal_sum that accepts a string argument and returns the sum of the ordinal values of each character in the string. The ordinal value of a character is its numeric Unicode code point in decimal. 2. Write code that creates a Python set containing each unique character in a string named my_string. For example, if the string is 'hello', the set would be {'h', 'e', 'l', 'o'} (in any order). Assign the set to a variable...
1. String Length Write a function that returns an integer and accepts a pointer to a C-string as an argument. The function should count the number of characters in the string and return that number. Demonstrate the function in a simple program that asks the user to input a string, passes it to the function, and then displays the function’s return value. c++
PYTHON QUESTION PLEASE!!
Write a function named problem3 that accepts two strings as the
arguments, returns the characters that occur in both strings. Test
case: the arguments are “apple@123” and “banana@#345”, your program
should return “a@3”.
Write a function named problem3 that accepts two strings as the arguments, returns the characters that occur in both strings. (20 pts) Test case: the arguments are "apple@123” and “banana@#345”, your program should return "a@3".
C++ clock.h /* Write a function get_hours that returns an int and accepts an int seconds_since_1970 parameter */ int get_hours(int seconds_since_1970); /* Write a function get_minutes that returns an int and accepts an int seconds_since_1970 parameter */ int get_minutes(int seconds_since_1970); /* Write a function get_seconds that returns an int and accepts an int seconds_since_1970 parameter */ int get_seconds(int seconds_since_1970); clock.cpp #include "clock.h" /* Write get_hours code to return hours given seconds since 1970 int */ /* Write get_minutes code to...
C++ Question! Write a function vector concatenateMyVectors(const vector& v, const vector& w) which returns the concatenation of the two vectors.