Menu

[Solved] C Programming Code Please Solve Problems 4 8 Functions Using Function Prototypes Variables Q37286868

C PROGRAMMING CODE!! Please solve problems 4-8 functions usingthe function prototypes and variables provided at the bottom. Thecode for up to #3 is below as well.

Problem 3 (the_gcd) Calculate and return the greatest common divisor of the two integer calling arguments. Find an algorithmProblem 6 (dot_prod) A vector dot product is an algebraic operation on two equal-length vectors The dot product of two vector#de fine SIZE 10 (void) (int a,int b)i int get_int int max two int sqrt_floor (int root); int the_gcd int perfect_num (int p)

int get_int() { int d; printf(“Input number: “); scanf(“%d”, &d); return d;}int max_two(int a, int b) { return (a > b ? a : b);}int sqrt_floor(int root) { int i = 0; while(i * i <= root) { i++; } return i – 1;}int the_gcd(int a, int b) { if (b == 0) return a; return the_gcd(b, a % b);}Problem 3 (the_gcd) Calculate and return the greatest common divisor of the two integer calling arguments. Find an algorithm online. Problem 4 (perfect_num) A perfect number is a positive integer that is equal to twice the sum of all of its factors (It can also be defined as a number that equals the sum of its factors excluding itself.) For example, 6 has the factors 1,2,3 and 6. 6 is a perfect number because 1+2+3+6 12. Given an integer as a calling argument, return the next largest perfect number. For example, if the calling argument is 5, the returned value should be 6 If the input argument is 6, the output should be 28. Problem 5 (prt_array) Make a function (that employs printf) to print the elements of the integer array that is passed in as a calling argument. To test this function, create and initialize an array of 11 integers in main. Print the array using this function. To test this function, create and initialize an array of 7 integers in main Print the array using this function Problem 6 (dot_prod) A vector dot product is an algebraic operation on two equal-length vectors The dot product of two vectors a-lal, az, аз, an] and b-[b1, b2, b3, bn] is Create and initialize two integer arrays (i.e., vectors) in main that contain 10 elements each. Display the vectors using the prt_array function; then calculate and output their dot product using this new function. Create and initialize two additional integer arrays in main that contain 5 elements each. Display the vectors using the prt_array function; then calculate and output their dot product using this new function. Problem 7 (prt_matrix) Create a function to print any given square 2D array of integers as a nicely formatted block. Do not use printf in this new function (or in main) to display the elements; rather, use prt array To test the function, create a 5×5 integer array in main and print it with this function. To test the function, create a 2×2 integer array in main and print it with this function. Problem 8 (sum_matrix) Create an integer function to sum all of the elements of a square 2D array provided through the calling arguments. Return the integer sum. #de fine SIZE 10 (void) (int a,int b)i int get_int int max two int sqrt_floor (int root); int the_gcd int perfect_num (int p) void prt_array (int a],int n) int dot_prod (int all,int b[l,int N); void prt matrix (int matrix[] [SIZE],int row,int column) int sum matrix (int matrix[] [SIZE],int row, int column); (int a, int b); Show transcribed image text Problem 3 (the_gcd) Calculate and return the greatest common divisor of the two integer calling arguments. Find an algorithm online. Problem 4 (perfect_num) A perfect number is a positive integer that is equal to twice the sum of all of its factors (It can also be defined as a number that equals the sum of its factors excluding itself.) For example, 6 has the factors 1,2,3 and 6. 6 is a perfect number because 1+2+3+6 12. Given an integer as a calling argument, return the next largest perfect number. For example, if the calling argument is 5, the returned value should be 6 If the input argument is 6, the output should be 28. Problem 5 (prt_array) Make a function (that employs printf) to print the elements of the integer array that is passed in as a calling argument. To test this function, create and initialize an array of 11 integers in main. Print the array using this function. To test this function, create and initialize an array of 7 integers in main Print the array using this function
Problem 6 (dot_prod) A vector dot product is an algebraic operation on two equal-length vectors The dot product of two vectors a-lal, az, аз, an] and b-[b1, b2, b3, bn] is Create and initialize two integer arrays (i.e., vectors) in main that contain 10 elements each. Display the vectors using the prt_array function; then calculate and output their dot product using this new function. Create and initialize two additional integer arrays in main that contain 5 elements each. Display the vectors using the prt_array function; then calculate and output their dot product using this new function. Problem 7 (prt_matrix) Create a function to print any given square 2D array of integers as a nicely formatted block. Do not use printf in this new function (or in main) to display the elements; rather, use prt array To test the function, create a 5×5 integer array in main and print it with this function. To test the function, create a 2×2 integer array in main and print it with this function. Problem 8 (sum_matrix) Create an integer function to sum all of the elements of a square 2D array provided through the calling arguments. Return the integer sum.
#de fine SIZE 10 (void) (int a,int b)i int get_int int max two int sqrt_floor (int root); int the_gcd int perfect_num (int p) void prt_array (int a],int n) int dot_prod (int all,int b[l,int N); void prt matrix (int matrix[] [SIZE],int row,int column) int sum matrix (int matrix[] [SIZE],int row, int column); (int a, int b);

Expert Answer


Answer to C PROGRAMMING CODE!! Please solve problems 4-8 functions using the function prototypes and variables provided at the bot… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *