Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Progress Monitoring Data Tracking Organizer

Authors: Teacher'S Aid Publications

1st Edition

B0B7QCNRJ1

More Books

Students also viewed these Databases questions

Question

Perform an Internet search. Discuss a company that uses EPLI.

Answered: 1 week ago

Question

How do you feel about employment-at-will policies? Are they fair?

Answered: 1 week ago