Write a number of C++ functions, and a test driver ( harness ) to test them with.
Functions:
double radians( double degrees )
double xCosXySinY( double x, double y )
int linspace( double data[ ], double dataMin, double delta, int nPoints )
-----Fills data[ ] with nPoints values, starting at dataMin and increasing in steps of delta.
-----Returns the number of array spots filled, ( normally nPoints ), or -1 in the case of errors ( bad input. )
int linspace( double data[ ], double dataMin, double delta, double dataMax )
-----Fills data[ ] with values, ranging from dataMin to dataMax in steps of delta
-----Returns the number of array spots filled, ( calculated ), or -1 in the case of errors ( bad input. )
#include <iostream>
#include <cmath>
using namespace std;
double radians(double degrees){
double pi = 2 * asin(1);
return degrees * pi / 180;
}
double xCosXySinY(double x, double y){
return (x * sin(radians(x))) + (y *
sin(radians(x)));
}
int linspace(double data[], double dataMin, double delta, int
nPoints){
try{
double val = dataMin;
for(int i = 0; i < nPoints;
++i){
data[i] =
val;
val +=
delta;
}
return nPoints;
}
catch(int e){
return -1;
}
}
int linspace(double data[], double dataMin, double delta, double
dataMax){
try{
double val = dataMin;
int count = 0;
for(double val = dataMin; val <=
dataMax; val += delta){
data[count++] =
val;
}
return count;
}
catch(int e){
return -1;
}
}
void printArr(double arr[], int count){
for(int i = 0; i < count; ++i){
cout << arr[i] << "
";
}
cout << endl;
}
int main(){
double arr[10], arr1[100];
linspace(arr, 0, 0.5, 10);
printArr(arr, 10);
int count = linspace(arr1, 0, 0.5, 7.5);
printArr(arr1, count);
return 0;
}
Write a number of C++ functions, and a test driver ( harness ) to test them...
Make sure to create the code with the given functions, and do not overlook them, do not create your own functions. This is an assignment that I did on my own and that's passed due, therefore, for educational purposes, I am interested to know what are other ways to properly program this. Please follow instructions as I am doing my best to fully understand every crucial detail in order to become a better programmer who is able to come up...
In C Write a couple of functions to process arrays. Note that from the description of the function you have to identify what would be the return type and what would be part of the parameter. display(): The function takes an int array and it’s size and prints the data in the array. sumArray(): It takes an int array and size, and returns the sum of the elements of the array. findMax(): It takes an int array and size, and...
c++ Write the following 2 functions and test them. Both of them need to be recursive functions. int sum(int n); // recursive version to calculate the sum of 1 + 2 + ..... + n int str_length(char s[]; // Returns length of the string s[] and the null character, '0\', is not counted in the length). Example of program execution; Enter a positive integer: 10 (user input) The sum of 1+ 2+....+10 is: 55 Enter a sentence: Hello World! (user...
Do the following: - Write and test a function that takes an array of doubles and returns the average of the values in the array - Write and test a function that takes an array of doubles and returns number of values in the array that are above the average of the values in the array - Write and test a function that takes an array of Strings and returns number of values in the array that start with an...
PLEASE HELP!!! C PROGRAMMING CODE!!!
Please solve these functions using the prototypes provided. At
the end please include a main function that tests the functions
that will go into a separate driver file.
Prototypes int R_get_int (void); int R_pow void R Jarvis int start); void R_fill_array(int arrayll, int len); void R_prt_array (int arrayl, int len) void R-copy-back (int from[], int to [], int len); int R_count_num (int num, int arrayll, int len) (int base, int ex) 3. Build and run...
A test harness program for testing sorting methods is provided with the rest of the textbook program files. It is the file Sorts.java in the ch11 package. The program includes a swap method that is used by all the sorting methods to swap array elements. Describe an approach to modifying the program so that after calling a sorting method the program prints out the number of swaps needed by the sorting method. Implement your approach. Test your new program by...
for this assignment you will be creating a series of functions for manipulating an array of data. The data will consist of randomly generated doubles. You should make the following functions: generate() - This function fills an array with random doubles in a specified range. This function takes four inputs: an array of doubles, an integer representing the size of the array, and two doubles representing the lower an upper bounds of the range random values. For example, the function...
Write a program that instantiates an array of integers named scores. Let the size of the array be 10. The program then first invokes randomFill to fill the scores array with random numbers in the range of 0 -100. Once the array is filled with data, methods below are called such that the output resembles the expected output given. The program keeps prompting the user to see if they want to evaluate a new set of random data. Find below...
Write a driver C++ program that will test the following functions in the same order they are written next. You can test your program by reading the following values: n1= 10 and n2= 20 from the user: The main program sends the values of the variables n1 and n2 to the function. The function calculates the average and sends it back to main program through the parameter list as call by reference parameter and will not use the return statement.
I need a c++ code please. 32. Program. Write a program that creates an integer constant called SIZE and initialize to the size of the array you will be creating. Use this constant throughout your functions you will implement for the next parts and your main program. Also, in your main program create an integer array called numbers and initialize it with the following values (Please see demo program below): 68, 100, 43, 58, 76, 72, 46, 55, 92, 94,...