Question
I need help on how to modify a function so that I could get how many times the function has been called during execution. In
I need help on how to modify a function so that I could get how many times the function has been called during execution. In C please.
Take three integer as input from the user. Write a two functions named as smallest(...) and largest(...). Each of the functions take three integer parameters and smallest(...) returns the smallest number among the three inputs, largest(...) returns the largest number among the three input numbers. ** Each case here can be treated here as a separate run of your program.
Case 1: Input: 3 12 19
Output: 3, 19 <-- 3 is returned by the smallest(...) function, while 19 is returned by the largest(...) function
Case 2: Input: -13 -2 1
Output: -13, 1
In this problem we are going to re-use functions defined in the Problem 1 and call them multiple times in a single run of this program. However, we modify both functions in a way such that when each function is called each time, it also prints the total number of calls made so far to that function. In other words, when a function gets a call, it remembers the number of calls. ** There can be multiple ways to do this. Think about how to do this using global vs local variables. Whats the significance of choosing storage classifier in both global vs local case.
Take an input integer N. Repeat the following process N time.
1. Take three input integer from the user and call functions defined in Problem 1.
2. Output return value from each of the functions. ** Here, one run of your program means N cases.
4 <-- N
Case 1: Input: 3 12 19
Output: Call made so far to smallest(...) 1
3
Call made so far to largest(...) 1
19
Case 2: Input: 6 7 8
Output: Call made so far to smallest(...) 2
6
Call made so far to largest(...) 2
8
Case 3: Input: -1 -2 -3
Output: Call made so far to smallest(...) 3
-3
Call made so far to largest(...) 3
-1
Case 4: Input: 7 90 112
Output: Call made so far to smallest(...) 4
7
Call made so far to largest(...) 4
112
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