Question: Write the definition of a function minMax that has five parameters. The first three parameters are integers. The last two are set by the function to the largest and smallest of the values of the first three parameters.
The function does not return a value.
The function can be used as follows:
******int a=31, b=5, c=19, big, small;
******minMax(a, b,c,&big,&small );
************/* big is now 31 */
************/* small is now 5 */
My Answer:
void minMax(int a,int b, int c, int *big, int *small){
if(a>b && a>c){
a= *big;
}
if(b>a && b>c){
b= *big;
}
else if(c>a && c>b){
c= *big;
}
else if(a<b && a<c){
a= *small;
}
else if(b<a && b<c){
b= *small;
}
else{
c= *small;
}
}
Errors:
Remarks:
*****⇒*****Your function did not change the values of class=code>big or
Don't have to give answers I'm fine with suggestions as how to solve this plz help!
2 3143 oler1s 671
Recognized Expert Contributor
I fail to see your question. Also, your post is somewhat troublesome to understand. The code should be placed in CODE tags. And I'm not sure what's going in that Errors/Remarks portion at the end.
Changing the arguments a,b and c inside the function is pointless unless you use them inside the funciton. These are copies of the ints used on the call.
These copies are destroyed when the function returns. Hence, the calling function does not see the change.
To change a variable in the calling funciton, you need to pass the address of the variable to the function.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Shilpesh |
last post by:
I have an issue in usage of utl_file package. I have setup
utl_file_dir parameters correctly on the database side.
Basically my goal is to convert csv files into table-structure. I do
not know the table structure as I have to create the table based on
the first line of the csv file. I stored all my csv files into one
directory and assign that directory in utl_file_dir paramater. When I
try to open the file in read mode - it gives me an...
|
by: lolomgwtf |
last post by:
I have a managed C++ method that wraps unmanaged code and creates a
managed object holding data retrieved form an unmanged one. I want
create an instance of this managed class in C#, pass it to this method
and have it set the instance to hold the right data.
>From what I've read it seems I should be able to pass C# objects to
managed C++ methods and it should just work; however, when I try it, my
C# instance comes out null. If I step...
|
by: jr |
last post by:
Sorry for this very dumb question, but I've clearly got a long way to go!
Can someone please help me pass an array into a function. Here's a starting
point.
void TheMainFunc()
{
// Body of code...
TCHAR myArray;
DoStuff(myArray);
|
by: WertmanTheMad |
last post by:
Ok,
This sounds dangerous (and yes I know it is)
But its in a controlled enviroment and I really need to know how to do
this.
How can I pass a Subquery for an Exist or In clause as a paramater
Something like this
CREATE procedure dbo.mytry
|
by: George Hester |
last post by:
Please take a look at this google artcle:
http://groups.google.com/groups?hl=en&lr=&frame=right&th=55d6f4b50f5f9382&seekm=411f370d%241%40olaf.komtel.net#link9
The op was having trouble with access denied using resizeTo. I am having the same issue
but the explanations in this article don't seem to apply here. I am not trying to
resize a window with content from a different server. This issue lies here.
What I do is make a popup...
| |
by: ncf |
last post by:
Ok, I've been tring to resolve this issue for some time now (~1 day
which is way longer than normal for me) to no avail.
I am reading a file into a list in memory, using a "%" delimited file
format (which allows for comments on lines beginning with "#"), and
some of the messages are not correctly copied.
I believe the problem may be somewhere around the strcpy() call, but am
not sure at all.
|
by: JIM.H. |
last post by:
Hello,
I am passing parameter through URL and in my page load I use
myStr = Request.QueryString("myStr") to get this parameter. This seems
working only for string, how should I pass a date and read it?
Thanks,
Jim.
|
by: agarwalpiyush |
last post by:
Hello,
I am going nuts with trying to get the following to work:
This is what I intend to do: I have a line in /etc/syslog.conf which I
need to delete based on ip-address provided to me in a variable.
Forgetting that variable part for now .. this is what i want in the
grep command:
grep -suob "\*\.\* *...@172.23.62.12"
|
by: sureshjayaram |
last post by:
I have problem with the code only with 64 bit big endian machine.
i have a member size_t val1 in my structure. The size of size_t is
32(unsigned int) in 32 bit machines and 64(unsigned long) in 64 bit
machines.
I am passing address of this variable to a different function (where it
accepts only pointer to unsigned int) unsigned int *. Basically passing
a unsigned long pointer instead of unsigned int pointer. I think the
value is...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |