Void type function to find the maximum of three given integer numbers"

Click For Summary

Discussion Overview

The discussion revolves around a homework problem requiring the creation of a void type function in C++ to find the maximum of three given integer numbers. Participants share code snippets, seek clarification on programming concepts, and express frustrations about online learning environments.

Discussion Character

  • Homework-related
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant presents a function to find the maximum of three integers but incorrectly refers to the development environment as "visual basic studio."
  • Another participant corrects the terminology, emphasizing the distinction between Visual Studio and Visual Basic.
  • There are discussions about the necessity of a main function in C++ programs, with some participants providing code examples to illustrate proper structure.
  • A participant expresses confusion about compiling the code due to missing components, such as semicolons, and seeks feedback on their implementation.
  • Several participants share their code, with variations in formatting and structure, and discuss the aesthetics of code organization.
  • One participant expresses frustration with the online format of their class, suggesting it hampers their learning experience.
  • Another participant argues that C++ is simple to learn and encourages more study, while sharing their own experience of self-learning the language.
  • A later reply reflects on the challenges of programming and the potential for burnout after extended periods of coding.

Areas of Agreement / Disagreement

Participants generally agree on the necessity of a main function in C++ and share similar views on the importance of code structure. However, there is disagreement regarding the effectiveness of online learning, with some participants expressing frustration while others suggest that self-study can be sufficient.

Contextual Notes

Some participants mention issues with compiling code due to syntax errors, and there are references to varying opinions on the quality of online education versus traditional classroom settings.

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 basic studio, any help would be appreciated.
 
Physics news on Phys.org
Well this is a pretty simple problem...
Code:
void max(int x, int y, int z)
{
  int max;
  max=x;
  if(y>max)max=y;
  if(z>max)max=z;
  cout<<"max b.itches: " << max<<endl;
}

Also there is no such thing as visual basic studio...
its Visual Studio, Visual basic is a programming lang.
 
Last edited:
yea I meant v-studio.net my brain is fried right now trying to figure this out.
I put what you gave me into the program and complied it with #include<iostream>
using namespace standard;
but there is no main function so how do I write it so that it will compile and run?
By the way nice job on the b.itches...
 
Uh hmm... don't they teach that in your first class? Every program must have 1 and only 1 main function ^^

//put the funciton declaration and prototype outside of the main function

int main ()
{

//call the function: sample integers 1,2,3.
max(1, 2, 3);

return 0;
}
 
re

You need put the function header right after <iostream>, with a semicolon. And nice count statement by the way.


#include <iostream>

using namespace std;

void max(int x, int y, int z);

...rest

int main()...
 
Thanks a lot

Well they don't teach us anything in class because the university decieded it would be a good idea to have the class online. Brilliant of them I think, I live 65 miles from the campus and if I need help before I am scheduled to be on campus then I am basically screwed. I knew I needed a main function but could not get the call to work I think I was missing ;'s, here is what I came up with thanks to you. Is it considered good form?
// 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 think this looks sexy.


Code:
#include <iostream>
using namespace std;

void max (int x, int y, int z);

int main ()
{

max(54, 27 ,35);

return 0;
}

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;
}
 
Ah yes and I see why, The book says it is acceptable to put the main statement after the functions but your looks much better and your spacing makes it look nice and coherant. Thanks again for your help.
 
Np. you will find out the more you work with it, pretty soon you will be putting all your function defintions and declations in different files insteedof putting everything with the main function. Then it will become neater.
 
  • #10
frogdogbb said:
Well they don't teach us anything in class because the university decided it would be a good idea to have the class online. Brilliant of them I think, I live 65 miles from the campus and if I need help before I am scheduled to be on campus then I am basically screwed.

I am sorry Frogdogbb that is not an excuse c++ is a pretty simple language to learn the basics of, most people learn it from the internet or the local library
you just need to study it more
 
  • #11
I taught myself C++ when i was 14, so this is true! but it took several years for me to get comfortable with it. Now i hate programming, it doesn't take long to get burned out with it.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 21 ·
Replies
21
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 12 ·
Replies
12
Views
2K
Replies
2
Views
2K
Replies
3
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 13 ·
Replies
13
Views
3K