Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C Language - Programming Exercise 1 - Passing variables By Reference (Calling By Reference) (2 marks) Exercise Objectives Declaring pointer variables Assigning pointer variables with

C Language - Programming
image text in transcribed
Exercise 1 - Passing variables By Reference (Calling By Reference) (2 marks) Exercise Objectives Declaring pointer variables Assigning pointer variables with references Accessing values using pointers Passing variables by reference Calling functions by references Using references to allow functions to return many values (in/out variables) Problem Description Open replit.com IDE, create a new repl (project) and name it "Lab115x1". Use this project to write and run a C program that performs the following: Declare the following functions as prototype and implement them after the main function SwapNums(), a function that receives two real (float) pointers a, b, and swaps them. [Note: This function not used to print values, just swap a and b] PerformCalc(), a function that receives two real numbers a, b and returns their addition, subtraction, multiplication and division values. (Hint: Your function prototype should be like this: void PerformCalc(float a, float b, float add, float sub, float .mul, float .div); (Note: in the same function you need to deal with division by zero problem) In the main function declare two real (float) numbers and y, and prompt the user to read both of them, then call the functions declared above as follows: Call Swap Nums() by passing the addresses of x and y o Call PerformCalc() function for x and y [Declare 4 float variables a, s, m, d to be passed as references in order to hold the addition, subtraction, multiplication and division values. ] Organize the output to appear as shown in the sample output below Download your project as .zip file and keep it within your file system (Desktop for example) Upload the project to the eLearning platform Sample Output Input the value of x 33.4 Please enter the value for y 17.9 After swapping x becomes 17.9 y becomes 33.4

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 Programming With Visual Basic .NET

Authors: Carsten Thomsen

2nd Edition

1590590325, 978-1590590324

More Books

Students also viewed these Databases questions