Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 10: Functions and Pointers (8 pts) The following code is intended to calculate the sum and product of two integers in a single function
Question 10: Functions and Pointers (8 pts) The following code is intended to calculate the sum and product of two integers in a single function call. #include "stdio.h', // calculate the sum and product of two integers void sum_and product (int sum, int product, int x, int y) sum = x + y ; product = x * y ; // example of calling sum_and_product main() int my_sum, my_product; int a = 10, b = 20; sum_and_product (my_sum, my_product, a, b)i printf("sum= %d, product = %d", my-sum, my-product); // Desired output of printf: sum = 30, product = 200 a. [3 pts] The given code does not work as intended. Explain why b. [5 pts] Revise the code of sum_and_product ( and main () so that they behave as desired. Test your code, and then cut and paste it in the space below. Highlight your changes in bold type. Note 1: You may not modify the number of arguments to the functions Note 2: You may not modify how many lines of code are in the functions, you may only modify the existing lines of C code
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started