Menu

[Solved] C Programming Code Please Solve 8 Functions Using Function Prototypes Variables Provided B Q37274527

C PROGRAMMING CODE!! Please solve the 8 functions using thefunction prototypes and variables provided at the bottom.

N.B. Functions other than main are not allowed to have any calls to scanf or printf with the exceptions of get_int, prt_arrayProblem 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)

N.B. Functions other than main are not allowed to have any calls to scanf or printf with the exceptions of get_int, prt_array, and prt_matrix. CISC 130 Lab 7 7.4 The required functions are as follows: Problem 0 (get_int) Create an integer function that prompts the user to input an integer, then confirm entry of the integer with the user (by echoing the integer to the user). This function may use scanf and printf.The function must return the integer entered by the user. Test this function from main; call this function and print the result from within main. This test/call/print process should be done similarly for each of the functions below. Problem 1 (max_two) Determine the larger of the two integers provided as calling arguments. That is, create a “max” function that returns the largest of its two input arguments. Test the function by calling get_int twice (in main) and use these numbers as the calling arguments (in main). Print the result (in main). Problem 2 (sqrt_floor) Calculate and return the floor of the input argument’s square root. Do not use any outside functions such as the C function sqrt. 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 N.B. Functions other than main are not allowed to have any calls to scanf or printf with the exceptions of get_int, prt_array, and prt_matrix. CISC 130 Lab 7 7.4 The required functions are as follows: Problem 0 (get_int) Create an integer function that prompts the user to input an integer, then confirm entry of the integer with the user (by echoing the integer to the user). This function may use scanf and printf.The function must return the integer entered by the user. Test this function from main; call this function and print the result from within main. This test/call/print process should be done similarly for each of the functions below. Problem 1 (max_two) Determine the larger of the two integers provided as calling arguments. That is, create a “max” function that returns the largest of its two input arguments. Test the function by calling get_int twice (in main) and use these numbers as the calling arguments (in main). Print the result (in main). Problem 2 (sqrt_floor) Calculate and return the floor of the input argument’s square root. Do not use any outside functions such as the C function sqrt.
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 the 8 functions using the function prototypes and variables provided at the bottom…. . . .

OR


Leave a Reply

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