The reason for giving a function a parameter is so that you can pass information into the function. Here, BigDog() reads the information that is needed, so there is no reason to use a parameter.
If you turn up all the warnings on your compiler, it should warn you that 'NumCount' is uninitialized. It is, indeed, uninitialized. Uninitialized variables are often a sign that you didn't do things quite like you thought you did. Here, you declare a variable called 'NumCount' (what's that supposed to mean, anyway? Of course any kind of count is a number...), but read 'KibblesCount'. Then you assign
from NumCount
into KibblesCount. Since NumCount is uninitialized, it could hold basically anything at this point, so you are playing around with a garbage value. This is not what you want to do. I assume you meant to assign the other way around, but there is no point to using another variable.
There is only one count variable that you need: KibblesCount. It is initialized within BigDog(), so we don't pass it, because there is nothing meaningful to pass. (The reason you were told it was undeclared is because it is undeclared
within main(). By putting a declaration "at the top", you are adding yet another variable - a global one - and arranging for main() to pass this uninitialized, global variable into BigDog().) Since BigDog() needs the variable, and we won't be passing it in, we declare it within BigDog(). We initialize it
by reading it in, and then use it.
Putting that all together, we get:
// By the way, don't just go around randomly #include'ing headers. You should// learn what each is for. In your case, you are only using things from <iostream>.#include <iostream>using namespace std;int BigDog() { int KibblesCount; cout << "How many kibbles should we feed the doggie?" << endl; cin >> KibblesCount; // Now it has a known value. cout << "I'm a lucky dog" << endl; cout << "I have " << KibblesCount << " doggie treats" << endl; cout << "RUFF RUFF RUFF" << endl; // Now we use KibblesCount directly. while (KibblesCount > 0) { cout << "Num num num num thanks!" << endl; KibblesCount--; } cout << "Ruh Roh! I Are All Out!" << endl;}int main(int argc, char *argv[]) { // Our function takes no parameters, so calling it looks like this: BigDog(); // I have taken away the pause because you should not artificially pause // your programs at the end. Instead, run them from the command line, or // using a batch file that implements the pause. // in C++, main() is a special function: you do not need to 'return 0;' at // the end. If main() reaches the end, it returns 0 automatically. This is // NOT the case with any other function; if you write a function that returns // a value, it must return something at the end (if the function hasn't // already returned in the middle). BigDog() is fine, however, because its // return type is 'void', meaning that it doesn't return a value.}
By the way, C++ is case sensitive. "Int" does not mean the same thing as "int", and "Cout" does not mean the same thing as "cout". You should get in the habit of being careful about these things, even when you're just talking about the code instead of writing it; that way you're less likely to mess things up when it matters. :)