the instructions say that my program should use two functions besides main. (One void function and one value returning function.) Could I perhaps make another value returning function for
1 2 3 4
if (numEnt % 2 == 0)
cout << numEnt << " is even." << endl;
void printAns (int numEnt){ //where it checks if number is even, off, positive or negative
something like this?
1 2 3 4 5 6 7 8 9 10 11 12 13 14
if (even== 0)
cout << numEnt << " is even." << endl; //if divisible by 2 then it's even
else
cout << numEnt << " is odd." << endl; //if it is not divisible by 2 then it's odd
if (numEnt >= 0)
cout << numEnt << " positive." << endl; //if number is greater or equal to 0 then it's positive
else
cout << numEnt << " is negative." << endl; //if number is less than 0 it's negative
}
int even (int numEnt){
numEnt % 2 = even
return even;
}
I guess you could make printAnswer return the value of the answer instead of printing it and then do something like cout << "Answer = " << printAnswer(numEnt) << endl;
Somewhat vague assignments were always my favorite, for sure.
You can have your function do it's calculations, as your printAnswer is doing. Once calculations are complete return a value back to your main function. I think returning boolean values would be the easiest.
Obviously this code won't compile, but you get the idea. You can call another function to get positive or negative the same way.