Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(a) What is the difference between call by reference and call by value? Discuss the different ways in which functions can modify variables in the

image text in transcribed

(a) What is the difference between call by reference and call by value? Discuss the different ways in which functions can modify variables in the environment in which they are called. [4 marks] (b) Write a short C program that demonstrates: i) An example of a function that uses calling by value. Create a main that declares and initializes two floats of your choice, and passes them into the function which returns the product of the two. Save your program to the file: lastName_firstName_EEEE1042Final_3bi.c and submit it together with your exam. For full marks you must adequately comment your code. [5 marks] ii) An example of a function that uses calling by reference. Create a main that declares and initializes two floats and passes them into the function that exchanges their values. Save your program to the file: lastName_firstName_EEEE1042Final_3bii.c and submit it together with your exam. For full marks you must adequately comment your code. [5 marks] iii) Repeat b)ii above, but now swapping two strings (char-arrays) "First string" and "Second string" rather than two floats. Save your program to the file: lastName_firstName_EEEE1042Final_3biii.c and submit it together with your exam. For full marks you must adequately comment your code. [6 marks]

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

Database Systems An Application Oriented Approach Complete Version

Authors: Michael Kifer, Arthur Bernstein, Richard Lewis

2nd Edition

0321268458, 978-0321268457

More Books

Students also viewed these Databases questions