473,788 Members | 2,828 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Issue with minMax() function and paramater passing

2 New Member
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!
Mar 1 '08 #1
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.
Mar 1 '08 #2
weaknessforcats
9,208 Recognized Expert Moderator Expert
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.
Mar 1 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
3863
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...
1
3552
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...
58
10181
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);
6
4523
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
7
3301
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...
11
1958
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.
1
955
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.
4
3233
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"
17
3010
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...
0
9656
marktang
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...
0
10366
Oralloy
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...
1
10112
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,...
0
9969
tracyyun
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...
0
8993
agi2029
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...
0
6750
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();...
0
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4070
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
2
3675
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.