1. ## Function definitions

Hey again Thanks for all the help on my project, the teacher hasn't grade it yet but hopefully I did everything correct and I was able to help one of my class mates with there code and got it to work without any code i had

Now she wants us to do a new project:
Write a program that ask the user for a number. Then displays the multiplication table for that number 0-10.

use the following function prototype and code the function definitions

int getNumber( );
void displayTable(int);

use a loop to calculate and display the table

I have it working but without the void displayTable(int); how could I make it including that?
Code:
```#include <iostream>

using namespace std;
//Prototypes
int getNumber( );
//void displayTable(int);

int main()
{
int firstNumber;

firstNumber=getNumber();

int Number;
for (Number=0; Number<=10; Number++)
{
cout<<firstNumber<<" x "<<Number<< " = "<<tableAnswer<<'\n';
}

system ("pause");
return 0;
}

int getNumber()
{
int Number;
cin>>Number;
return Number;
}

/*void displayTable(int)
{
int Number;
for (Number=0; Number<=10; Number++)
cout<<Number;
}
*/```

2. All of this goes inside your displayTable() function definition:
Code:
``` int Number;
for (Number=0; Number<=10; Number++)
{
cout<<firstNumber<<" x "<<Number<< " = "<<tableAnswer<<'\n';```
Then, you call the displayTable() function from main, the same way you called getNumber() from main.

Your main function should just call those two functions, and then return... It should hand-off all of the "work" to the other functions.

And, you are using the variable "Number" for two different things, which you can sometimes get away with, but it's generally bad practice.... It's OK to use "counting" variables names (usually x, y, i, j) in several different places like that, but you shouldn't use the same name for your user-input and for a counting variable. It would be perfectly acceptable to use the name "firstNumber" inside and outside the getNumber() function.

Of course, you'll have to pass the value of firstNumber into the displayTable() function, and there is no harm in using that same name again inside displayTable().

----------------------------------------------------------------
P.S.
Your function definiton needs some work. The function prototype and the first line of the function definition should not be exactly the same... they have different requirements. The prototype just needs the variable types (i.e. int) for the variables passed-in. The function definition also needs variable names (names to be used inside the function) for the passed-in values.

I suggest you start with a simple version of displayTable() that just displays the value of firstNumber. Then, add the 1st calculation and get that working. Then, add the loop. ...It's much easier if you "develop" your program one step at a time.

You might want to review the differences between a function prototype, the first line of a function definition, and a function call... It can get confusing because they all look similar.

In a more complicated program, you might have several function calls to the same function, but there will be only one function prototype and one function definition. Each of those calls can pass-in different variable names, as long as the variable types are correct. (The name isn't getting passed-in, only the value assigned to the name.) And, each of those calls might assign the return value to a different variable name, as long as the type is correct. (Again, the function returns a value.) ....Confused yet?

...and I was able to help one of my class mates with there code and got it to work...
It's a very good idea to get into a study group. It's easy to "get stuck" for hours on a simple concept, or on a simple bug, and somebody in the group can usually help you through it. Just make sure you understand what "the group" is doing, and do your own work... or at least use your own variable names.

3. Hehe yes been confused >_<
mmm do you mean doing this stuff?

Code:
```#include <iostream>

using namespace std;
//Prototypes
int getNumber( );
void displayTable(int);

int main()
{
int firstNumber;

firstNumber=getNumber();

system ("pause");
return 0;
}
//function definitions
int getNumber(numberInput)
{
int numberInput;
cin>>numberInput;
return numberInout;
}

void displayTable(int firstNumber)
{
int Number;
for (Number=0; Number<=10; Number++)
{
cout<<firstNumber<<" x "<<Number<< " = "<<tableAnswer<<'\n';
}```
It tells me i am doing something wrong with this part
Code:
```//Prototypes
int getNumber( );
void displayTable(int);

int main()
{
int firstNumber;

firstNumber=getNumber();```
Yeah I was sorta in a group thing with my teacher today but this is due on Sunday and I have classes tomorrow so it doesn't leave me much time to do a study group lol last project I was really stuck took me about 4 days and most of those days were sleepless >_<

Thank you for explaining everything it aids to my learning lol even though I have o learn backwards cause I am a visual leaner so I look at the code first and then try to figure out how it works with what you wrote hehe Thanks a lot

4. OF course it's wrong!
Remember your previous lesson: the function takes one argument, but you pass NONE!
About declarations and definitions... I recommend that you put variable names in declarations AND definitions because usually compilers use your declarations for intellisense (eg to show you what parameters a function takes) and it's very vague sometimes hard to know what type of arguments it takes if there's just two "int." Instead, put names on them in the declaration instead and you'll find it easier. It should work in both C and C++.

5. Also, first you should get the number, and then pass it to function that will display table. At the moment you're doing it in wrong order.

6. Wait which part is wrong??

7. Fix your function call and use the debugger to find out. You can do that, can't you?

8. no I've never really done function calls before. I was only able to make it work the 1st way I did it but I wanted to use the other function too.

9. Then how come you are using functions if you've never learned how to use them?

10. because its a project

11. Regardless. You shouldn't use what you don't know.
Take some time to read a tutorial.

You can also declare default parameters for functions, so that you do not have to pass arguments.
such as
Code:
```int Function(int = 10);

int Function(int x)
{
return x;
}```
if no argument is passed then it will return 10 as the default

maybe that will help clarify

13. Perhaps that's overkill since lifeis2evil is still new to functions.

14. its not overkill. it is a very useful part of the language and it is not like it's that hard.