C/C++ Need Help With C++ Void Function: Find Max of 3 Ints (VS.NET)

  • Thread starter Thread starter frogdogbb
  • Start date Start date
  • Tags Tags
    C++ Function
AI Thread Summary
The discussion revolves around a homework problem requiring the creation of a program that utilizes a void function to find the maximum of three integers. The initial poster sought assistance in writing and running the program in Visual Studio.NET. They later provided a working code snippet that defines a function to determine the maximum value among three integers and outputs it. However, a participant raised a concern regarding the definition of "finding" the maximum, suggesting that merely printing the value does not constitute finding it; instead, storing it in a variable would be more appropriate. The conversation also touched on the concepts of passing parameters by value versus by reference, explaining how this can impact the original values in the context of function calls, particularly with primitive data types. The discussion highlights the nuances of function definitions and parameter handling in programming.
frogdogbb
Messages
45
Reaction score
0
I have to answer a homework problem due today that I am not sure how to do the problem reads.
"Write a program that calls a void type function to find the maximum of three given integer numbers"
We use visual studio.net, any help would be appreciated and I would like to be able to compile it and run the program so I can figure out how it works.
Thanks
 
Technology news on Phys.org
never mind

I got it thanks anyway
// 7.3.cpp : Defines the entry point for the console application.
#include <iostream>
using namespace std;
void max(int x, int y, int z)
{
int max;
max=x;
if(y>max)max=y;
if(z>max)max=z;
cout<<"max= " << max<<endl;
}
int main ()
{
void max (int x, int y, int z);
max(54, 27 ,35);

return 0;
}
 
I got a problem with that: Your problem said "find" the maximum value. Well, just printing it to the screen is not "finding it" as far as I'm concerned. You know, now if you "stored" it to some variable name, then to me that would be considered "finding it". Suppose that might be a good thread in some "philosophy of computation" forum. Just what does "finding" it really mean?
 
Last edited:
A void function is really just a subroutine. Specifying void as the return type means you don't include the final "return 0;" or whatever return value.

When you call a function, keep in mind passing by value or passing by reference can sometimes affect your original value.

If youre calling a value type, like Int, Char, Long etc, pass by val means your value sits on the stack and gets copied for use, so the copy doesn't affect the original. But never assume a pass by val leaves the original untouched
 
Thread 'Star maps using Blender'
Blender just recently dropped a new version, 4.5(with 5.0 on the horizon), and within it was a new feature for which I immediately thought of a use for. The new feature was a .csv importer for Geometry nodes. Geometry nodes are a method of modelling that uses a node tree to create 3D models which offers more flexibility than straight modeling does. The .csv importer node allows you to bring in a .csv file and use the data in it to control aspects of your model. So for example, if you...
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...
Back
Top