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

  • Context: C/C++ 
  • Thread starter Thread starter frogdogbb
  • Start date Start date
  • Tags Tags
    C++ Function
Click For Summary

Discussion Overview

The discussion revolves around a homework problem requiring the implementation of a C++ void function to find the maximum of three integers using Visual Studio .NET. Participants explore the function's design, its implications, and the interpretation of "finding" a maximum value.

Discussion Character

  • Homework-related
  • Technical explanation
  • Conceptual clarification

Main Points Raised

  • One participant describes the homework problem and requests assistance in writing a C++ program that includes a void function to find the maximum of three integers.
  • Another participant shares their solution, including a code snippet that defines a void function to determine and print the maximum value of three integers.
  • A different participant challenges the interpretation of "finding" the maximum, suggesting that merely printing the value does not constitute finding it, and proposes a philosophical discussion on the meaning of "finding" in computation.
  • Another participant explains the nature of void functions, emphasizing that they do not return a value and discusses the implications of passing parameters by value versus by reference in C++.

Areas of Agreement / Disagreement

Participants express differing views on what it means to "find" the maximum value, with some focusing on the technical implementation and others questioning the conceptual understanding of the task. The discussion remains unresolved regarding the philosophical implications of the term "finding."

Contextual Notes

There are unresolved assumptions regarding the definition of "finding" a maximum value and the implications of using void functions in C++. Additionally, the discussion touches on the effects of parameter passing methods on variable values.

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;
count<<"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
 

Similar threads

  • · Replies 17 ·
Replies
17
Views
4K
Replies
20
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 36 ·
2
Replies
36
Views
7K
Replies
14
Views
4K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 6 ·
Replies
6
Views
13K
  • · Replies 17 ·
Replies
17
Views
2K