In C++, when should I use the void command?
Code:
#include <iostream>
#include <math.h>
using namespace std;
int increase(int num);
int decrease(int num);
int main()
{
int n;
cout << "Enter a number and press ENTER: ";
cin >> n;
cout << "Function returned: ";
if (n <= 0)
{
increase(n);
}
else
{
decrease(n);
}
return 0;
}
int increase(int num)
{
for (int n; n <= 0; n++)
{
cout << n << ", ";
}
}
int decrease(int num)
{
for (int n; n >= 0; n--)
{
cout << n << ", ";
}
}
I'm learning functions right now it says in my book that using void won't return a value, however I'm a bit confused by this. When and where should I use the word void? If I change the functions to use void it doesn't change anything in the final result. Hope the question makes since.
Sorry if I didn't really explain what I'm doing here.
Bookmarks