Whew, okay. Let's break this down.
First, your function prototypes need the variable's type you're passing to it. I usually just copy and past the function "header".
1 2 3 4 5 6 7 8
|
int findLargest();
void showResult(large);
// Needs variable type like so:
int findLargest(int num1, int num2, int num3);
void showResult(int large);
// Or even this works:
int findLargest(int, int, int);
void showResult(int);
|
Second, if you are going to use a variable (int num1..etc) in a function, you need to pass it to that function. The function can't "see" the variable unless you show the variable to it. This is done in the parameters like so:
1 2 3 4 5 6 7 8
|
// Calling the function:
showProgInfo(num1, num2, num3, large);
// Inside the () is sending those variable's value to the function
/*-----------------------------------------------------------------*/
// Function "header":
void showProgInfo(int num1, int num2, int num3, int large) {
// Inside the () is where you tell the function what type of values you sent them
// and declares them for your function.
|
Third, like above the () after the function name are for parameters, not arguments.
1 2 3 4 5 6
|
int findLargest (int i=1, i>3, i++)
// Here you are trying to put a For loop argument in the parameters of the function.
// The compiler is looking for variables it needs to perform the function.
// This is what you're looking for:
int findLargest (int num1, int num2, int num3)
{
|
Fourth, your For loop (once you get it out of the function parameter) will never initialize because you are telling it to start counting when int i is greater than 3, but you have it equal to 1. Your For loop argument is saying i is 1, when i is greater than 3 start counting, add 1 to i every time you count. Also, the 3 different For loop arguments need to be separated by a ";" and not a ",".
Your program doesn't need a for loop in it, but just for future reference:
1 2 3
|
for (int i=1, i>3, i++)
// Needs to be:
for (int i = 1; i < 3; i++)
|
Fifth, a better way to do the if/else statements would be using the &&(and) ||(or) logic operators. I don't know if you've learned them yet, but they are pretty easy to learn, and very useful.
http://www.cplusplus.com/doc/tutorial/operators/
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
int findLargest (int num1, int num2, int num3)
{
int large;
if (num1 > num2 && num1 > num3)
{
large = num1;
} else if (num2 > num1 && num2 > num3)
{
large = num2;
} else {
large = num3;
}
return large;
}
|
Finally, clean up those typos. If you call a function and misspell the function name, the compiler won't know what you're trying to call. I'd recommend using a good compiler that can catch those typos and other syntax problems. I personally use CLion, but Visual Studios and others are just as good.
I am also a beginner, and with only about 3 months of C++ under my belt.
So if anyone who has more experience can verify or correct anything I've written, I'm open to some constructive criticism. Here are some study aids for some of the problems you're having:
http://www.cplusplus.com/doc/tutorial/functions/
http://www.cplusplus.com/doc/tutorial/namespaces/
Practice is key jaybee. Let me know if you have any more problems.