Answered step by step
Verified Expert Solution
Question
1 Approved Answer
You must use functions and pointers to write this C program. there will be two codes that is part 1 and part 2. read the
You must use functions and pointers to write this C program. there will be two codes that is part 1 and part 2. read the instructions and tips. Use %lf(long float) instead of float(%f) when required.Use camel case for naming variables. Please add relevant comments to explain how you did it. The output has to be exactly the same as the instructions given , even the spelling and spacing has to be the same. Please post as early as possible. I have a deadline.
Functions and Pointers This lab will give you experience writing software that makes use of Functions and Pointers Part I - Divisors Sum [4 points) In mathematics, a divisor of an integer n, also called a factor of n, is an integer m that may be multiplied by some integer to produce n. In this case, one also says that n is a multiple of m. An integer n is divisible by another integer m ifm is a divisor of n; this implies dividing n by m leaves no remainder. Now assumem and p are two divisors of n such that n = mx p, and let us call these two numbers "pair divisors" of n. In part I, you are about to write a C program that receives an input number n and a query number and checks if there is any "pair divisors" of n that their sum is equal to the query number (checks whether q ==p+m). If there is any pair divisors, your code should return one of those pairs. The Code to be Written: 1. You are to write a C program, in a file called Lab5a.c 2. You must write a function that computes the pair divisors of n and returns one that their sum equals q (if there is any). This function is called by the "main" function and sets the pair values it finds via pointer addresses. This should be of the form of this prototypes void get PairDivisor(int n, int 4. int* mAddress, int* pAddress) check to see that you used a C-language function, The variables mAddress and pAddress are the addresses to values of found p and m. Your algorithm should handle the cases where it does not find any result. Your programs should work for any positive integer values of , (ie both > 1 and > 1). Sample Outputs Please enter an input number n: 100 Please enter a query number a: 25 -5, P-20, *p - 100, and *p - 25 page 2 Please enter an input number n: 77 Please enter a query number q: 18 n-7, P - 11, *p - 77, and mop - 18 Please enter an input number n: 234 Please enter a query number a: 133 The program could not find any pair divisors for these inputs Part II - The Depth Guage Problem [6 points) Storage tanks are containers that hold liquids, compressed gases or mediums used for the short- or long-term storage of heat or cold. Storage tanks are available in many shapes: vertical and horizontal cylindrical; open top and closed top; flat bottom, cone bottom, slope bottom and dish bottom. Liquids are often stored in elliptical (cylindrical) storage tanks as shown in Figure 1. To measure the volume of liquid in the tank, a depth gauge (measuring stick) can be used. It is inserted into an opening at the top and the level of liquid on the gauge can be used to determine the amount of liquid in the tank. Imagine the tank has width , height h and length len (all in meters) We look at inserting a measuring stick that is already calibrated in units of 10 centimeters. This measuring gauge can be inserted into an opening at the top of the tank and used to measure the depth of the liquid in the tank. For this part, your task will be to write a C program to compute a value for a specific depth showing the volume of liquid in the tank for that depth (eg. 50cm or 370cm - always a multiplication of 10 centrimeters) Your programns should work for any values of w, h and len, and not just the specific values in the sample outputs below. We are assuming here that the user inputs valid numbers all the time. Sample Outputs page 3 Figure 1: Sample image for Part II. Enter the width of the tank (in meters): 8 Enter the height of the tank (in meters): 4 Enter the length of the tank (in meters): 7 Enter the specific depth on the measuring stick (in centimeters): Depth 10.00 cm: Volume 1.17 cubic meters 10 Enter the width of the tank (in meters): 5 Enter the height of the tank (in meters): 6 Enter the length of the tank (in meters): 7 Enter the specific depth on the measuring stick (in centimeters): Depth 30 cm: Volume 3.08 cubic meters 30 Enter the width of the tank (in meters): 9 Enter the height of the tank (in meters): 10 Enter the length of the tank (in meters): 12 Enter the specific depth on the measuring stick (in centimeters): 900 Depth 900 cm: Volume 804.02 cubic meters Enter the width of the tank (in meters): 18 Enter the height of the tank (in meters): 22 3:33 ..SO (22) page 4 Methodology for Part II: Formula +2/+2+3/1+3) +10 4 of 6 page 5 Hint: It is probably easier to imagine the tank on its side so that the depth gauge is inserted horizontally. If you do this you must express the equation as a function of y and integrate that function. The Code to be Written: You must use a C 1. You are to write a C program, in a file called Lab5b.c language function in this 2. You must write a function that implements Equation 1. code 3. You must also write a function that compute the volume of the liquid using trapezoidal inte gral and function you wrote for Equation 1. This should be of the form of this prototype. void trapezoidal integral (double depth, int n, double width, double height, double length, double* integral result) For part b, many of you have mentioned that the numerical integration method you have implemented results in slightly different numbers than what is asked in the assignment file. Please note that as the integration method can be repeated with the same lank size parameters and different depth, for this lab, we are assuming a fixed size h for each set of parameters, i.e. you may obtain the value of h by considering the formula della heighin (and not depth). Best, 116 795 91.18
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